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



--- Comment #4 from Walter Bright <bugzi...@digitalmars.com> 2011-04-18 
14:28:14 PDT ---
// Suitable for inclusion in test suite

struct A {}

void foo(bool cond){}

void main()
{
    A a;
    int i;

    static assert(!__traits(compiles, assert(a)));      // type A does not have
a boolean value
    static assert(!__traits(compiles, assert(i || a))); // type A does not have
a boolean value
    static assert(!__traits(compiles, assert(0 || a))); // OK

//    if(a) {}        // type A does not have a boolean value
//    if(i || a) {}   // type A does not have a boolean value
//    if(0 || a) {}   // type A does not have a boolean value

    static assert(!__traits(compiles, foo(a)));         // cannot implicitly
convert type A to bool
    static assert(!__traits(compiles, foo(i || a)));    // OK
    static assert(!__traits(compiles, foo(0 || a)));    // OK
}

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

Reply via email to