Template question

BCS ao at pathlink.com
Thu Feb 22 15:03:31 PST 2007


Reply to Michiel,

> Michiel wrote:
> 
[...]
> 
> Thanks for the suggestion, anyway! I hadn't thought of it.
> 

How about this, it might work.

template set(T, U...)
{
 static if(U.length == 0)
 {
  Set!(T) set() {
  return new Set!(T);
  }
   Set!(T) set(T e1) {
   auto result = new Set!(T);
   result.add(e1);
   return result;
  }
 }
 else
 {
   Set!(T) set(T e1, U rest) { // line 287
   auto result = new Set!(T);
   result.add(e1);
   foreach (element; rest)
   {
    result.add(element);
   }
   return result;
  }
 }
}





More information about the Digitalmars-d mailing list