[Issue 10874] New: std.conv.to should support conversion from ulong to int-based enum

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 22 18:54:50 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10874

           Summary: std.conv.to should support conversion from ulong to
                    int-based enum
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: hsteoh at quickfur.ath.cx


--- Comment #0 from hsteoh at quickfur.ath.cx 2013-08-22 18:54:49 PDT ---
Code:
------
import std.conv;
enum Test { a = 0 }
void main() {
    ulong l = 0;
    auto t = l.to!Test;
}
------

DMD output:

/usr/src/d/phobos/std/conv.d(281): Error: template std.conv.toImpl does not
match any function template declaration. Candidates are:
/usr/src/d/phobos/std/conv.d(337):        std.conv.toImpl(T, S)(S value) if
(isImplicitlyConvertible!(S, T) && !isEnumStrToStr!(S, T) && !isNullToStr!(S,
T))
/usr/src/d/phobos/std/conv.d(449):        std.conv.toImpl(T, S)(ref S s) if
(isRawStaticArray!S)
/usr/src/d/phobos/std/conv.d(465):        std.conv.toImpl(T, S)(S value) if
(is(typeof(S.init.opCast!T()) : T) && !isExactSomeString!T)
/usr/src/d/phobos/std/conv.d(496):        std.conv.toImpl(T, S)(S value) if
(!isImplicitlyConvertible!(S, T) && is(T == struct) && is(typeof(T(value))))
/usr/src/d/phobos/std/conv.d(546):        std.conv.toImpl(T, S)(S value) if
(!isImplicitlyConvertible!(S, T) && is(T == class) && is(typeof(new T(value))))
/usr/src/d/phobos/std/conv.d(281):        ... (16 more, -v to show) ...
/usr/src/d/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
!(Test)(ulong)
/usr/src/d/phobos/std/conv.d(281): Error: template instance toImpl!(Test)
errors instantiating template
test.d(5): Error: template instance std.conv.to!(Test).to!(ulong) error
instantiating

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list