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

2011-03-27 Thread Andrej Mitrovic
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!(

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

2011-03-27 Thread Andrej Mitrovic
Wow not a minute later and I get bitten by my own solution. A C function returned 1 for a supported feature, and -1 otherwise. And of course -1 got converted to true, so then I had a bug in my code. Damn silly C functions which return -1 when they should return 0. Or damn me for not RTFM'ing.

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

2011-03-28 Thread Jesse Phillips
Andrej Mitrovic Wrote: > Wow not a minute later and I get bitten by my own solution. A C > function returned 1 for a supported feature, and -1 otherwise. And of > course -1 got converted to true, so then I had a bug in my code. > > Damn silly C functions which return -1 when they should return 0.

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

2011-03-28 Thread Andrej Mitrovic
It can't implicitly convert an int to a bool. The C function returns an int.