December 07, 2013 [Issue 11704] New: std.conv.to fails from string to std.typecons.Typedef | ||||
---|---|---|---|---|
| ||||
https://d.puremagic.com/issues/show_bug.cgi?id=11704 Summary: std.conv.to fails from string to std.typecons.Typedef Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2013-12-07 07:09:15 PST --- void main() { import std.typecons: Typedef; import std.conv: to; alias T = Typedef!int; string x = "5"; T y = to!T(x); } dmd 2.065alpha gives: ...\dmd2\src\phobos\std\conv.d(281): Error: template std.conv.toImpl does not match any function template declaration. Candidates are: ...\dmd2\src\phobos\std\conv.d(346): std.conv.toImpl(T, S)(S value) if (isImplicitlyConvertible!(S, T) && !isEnumStrToStr!(S, T) && !isNullToStr!(S, T)) ...\dmd2\src\phobos\std\conv.d(458): std.conv.toImpl(T, S)(ref S s) if (isRawStaticArray!S) ...\dmd2\src\phobos\std\conv.d(474): std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(typeof(S.init.opCast!T()) : T) && !isExactSomeString!T) ...\dmd2\src\phobos\std\conv.d(506): std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(T == struct) && is(typeof(T(value)))) ...\dmd2\src\phobos\std\conv.d(556): std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(T == class) && is(typeof(new T(value)))) ...\dmd2\src\phobos\std\conv.d(281): ... (16 more, -v to show) ... ...\dmd2\src\phobos\std\conv.d(281): Error: template std.conv.toImpl(T, S)(S value) if (isImplicitlyConvertible!(S, T) && !isEnumStrToStr!(S, T) && !isNullToStr!(S, T)) cannot deduce template function from argument types !(Typedef!(int, 0))(string) temp.d(6): Error: template instance std.conv.to!(Typedef!(int, 0)).to!(string) error instantiating A workaround: T y = T(to!int(x)); -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation