why no to!bool(0) or to!bool(1) ?

growler growlercab at gmail.com
Mon Aug 26 21:08:46 PDT 2013


Is there any reason why the following code fails to compile?

---
auto bfalse = to!bool(0);
auto btrue = to!bool(1);
---
dmd2/src/phobos/std/conv.d(329): Error: template std.conv.toImpl
cannot deduce template function from argument types !(bool)(int)


I can use a string, like so:
---
auto bfalse = to!bool("false");
auto btrue = to!bool("true");
---
...but usually the database column is an INTEGER type.

I can cast(bool)(0) or cast(bool)(1) no problem but I much prefer
to!bool.

Thanks,
G.


More information about the Digitalmars-d-learn mailing list