Top level array constness discarding and Variant
cybevnm
cybevnm at gmail.com
Mon Jul 30 13:44:56 PDT 2012
During initializing Variant, D discards top level const of array, which
leads to little unintuitive behaviour. Consider code:
import std.stdio;
import std.variant;
void main()
{
const int[] arr;
Variant v = Variant( arr );
writeln( v.peek!( typeof( arr ) )() );
writeln( v.peek!( const(int)[] )() );
writeln( v.type() );
}
...and output:
%dmd main.d && ./main.d
null
7FFF358AE298
const(int)[]
As you can see peek works successfully not for original array type, but
for type without top level const. Is Variant supposed to work in that way ?
More information about the Digitalmars-d-learn
mailing list