Constrained Templates

Simen kjaeraas simen.kjaras at gmail.com
Mon Jun 14 06:59:20 PDT 2010


Leandro Lucarella <llucax at gmail.com> wrote:
> it would be nice
> to have some sort of way to tell the compiler to write the template
> constraints for us (the obvious ones at least, there might be other
> template constraints desired besides the ones the ones the compiler can
> figure out). This way, the errors can be improved without user
> intervention.

How's about @optional? Marks an entire function as optional, i.e. will
not be included if it does not compile.

struct foo( T ) {
   @optional
   void bar( ) { // Will not exist if T cannot be flabbergasted.
     T tmp;
     t.flabbergast( );
   }
}

-- 
Simen


More information about the Digitalmars-d mailing list