www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.variant.coerce() strange behaviour

I'm using the variant module from Phobos and I use the coerce function 
to convert types:

Variant v="2";
int n=v.coerce!(int);

But an exception is thrown. The documentation states:

If the VariantN object is a string, a parse of the string to type T is 

But it doesn't do that. What did I do wrong?


import std.variant;

void main ()
	Variant v="2".dup;
	int n=v.coerce!(int);
Error: Variant: attempting to use incompatible types char[] and real
Mar 09 2008