digitalmars.D.learn - std.variant.coerce() strange behaviour
- qadasd (19/19) Mar 09 2008 I'm using the variant module from Phobos and I use the coerce function
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
attempted.
But it doesn't do that. What did I do wrong?
-----------
test.d:
import std.variant;
void main ()
{
Variant v="2".dup;
int n=v.coerce!(int);
}
------------
Runtime:
Error: Variant: attempting to use incompatible types char[] and real
Mar 09 2008








qadasd <asd asd.vi>