"static if" is awesome

Sean Kelly sean at f4.ca
Thu Feb 23 19:40:00 PST 2006


It's how D simplifies everyday programming tasks that really sells me on 
this language.  'Atomic' in Ares now supports increment and decrement 
operations for numeric and pointer types only, and it does so without 
any weird template machinations or duplicated code:

struct Atomic(T)
{
     T load();
     void store( T newval );
     bool storeIf( T newval, T equalTo );

     static if( isValidNumericType!(T) )
     {
         T increment();
	T decrement();
     }
}

Try that in C++ :-P


Sean



More information about the Digitalmars-d mailing list