Constrained Templates

Simen kjaeraas simen.kjaras at gmail.com
Mon Jun 14 09:11:22 PDT 2010


Don <nospam at nospam.com> wrote:

> This can be trivially shown to be NP-complete.
>
> void bar(T)()
> {
>     static if ( big_function!T) {
>       T t;
>       t.flabbergast( );
>     }
> }
>
> Compiler cannot determine if T needs flabbergast(), unless it evaluates  
> big_function. Which can be arbitrarily complicated.

But how does the compiler decide whether or not to include that code
usually? Would it not then also have to evaluate big_function?


> We're taking the approach of making the default error message in such  
> cases as helpful as possible.

Which is likely a better choice. The idea just hit me, and I decided
to probe for reactions.

-- 
Simen


More information about the Digitalmars-d mailing list