[Issue 10909] New: std.conv.to!(bool)(int): conversion from integer to bool

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 26 22:46:05 PDT 2013


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

           Summary: std.conv.to!(bool)(int): conversion from integer to
                    bool
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: growlercab at gmail.com


--- Comment #0 from growlercab at gmail.com 2013-08-26 22:46:03 PDT ---
Improve std.conv.to!bool(int) to convert from integer to bool.

Compiling 0.to!bool gives the following compiler error:

Error: template std.conv.toImpl cannot deduce template function from argument
types !(bool)(int)

I would expected the following snippet to compile and throw no assertions...

---
import std.conv;

void main() {
    assert(0.to!bool == false);
    assert(1.to!bool == true);


    int ival = 1;
    assert(ival.to!bool == true);

    ival = 0;
    assert(ival.to!bool == false); 


    // Could follow C++ implicit conversion rules perhaps? 
    // Where non-zero == true
    ival = 55;
    assert(ival.to!bool == true);
}
---

-- 
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