March 09, 2008 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 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 |
Copyright © 1999-2021 by the D Language Foundation