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 ?

Reply via email to