On 26.04.2016 13:26, Marc Schütz wrote:

Currently, there is no boolean short-cut evaluation in template
constraints, see:

     bool foo()() {
         pragma(msg, "foo");
         return true;
     }

     bool bar()() {
         pragma(msg, "bar");
         return true;
     }

     void main() {
         static assert(__traits(compiles, foo() || bar()));
     }

Prints "foo" and "bar", even though bar() wouldn't need to be evaluated
anymore after foo() returned true.

There sometimes is short-cut evaluation. This only prints "Foo":

template Foo(){
    pragma(msg, "Foo");
    enum Foo=true;
}
auto bar()(){
    pragma(msg, "bar");
    return true;
}
void main(){
    static assert(Foo!()||bar());
}

I don't see the point of the different behaviour for those cases.

Reply via email to