std.conv.to can't convert to bool?

Andrej Mitrovic none at none.none
Sun Mar 27 18:30:18 PDT 2011


import std.stdio;
import std.conv : to;

void main()
{
    uint state = 1;
    writeln( to!bool(state) );
}

D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\conv.d(99): Error: template std.conv.toImpl(T,S) if (!implicitlyConverts!(S,T) && isSomeString!(T) && isInputRange!(Unqual!(S)) && isSomeChar!(ElementType!(S))) does not match any function template declaration
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\conv.d(99): Error: template std.conv.toImpl(T,S) if (!implicitlyConverts!(S,T) && isSomeString!(T) && isInputRange!(Unqual!(S)) && isSomeChar!(ElementType!(S))) cannot deduce template function from argument types !(bool)(uint)
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\conv.d(99): Error: template instance errors instantiating template
boolConv.d(9): Error: template instance std.conv.to!(bool).to!(uint) error instantiating

What's the big problem with converting an int/uint to bool? I'm using a cast for now.


More information about the Digitalmars-d-learn mailing list