Template question

Michiel nomail at please.com
Thu Feb 22 13:14:28 PST 2007


BCS wrote:

> would this work?
> 
> auto x = Set!(int);
> 
> it's not quite as clean but...

It would have to be:

auto x = new Set!(int);

> If you don't like that
> you could try having set used as above take 2 things plus a tuple, then
> have a version of the template that takes one type and has function that
> take one or zero arguments
> 
> Set!(T) set(T, U, V...)(T e1, U e2, V elements) {...}
> 
> template set(T)
> {
> Set!(T) set(T e1) {...}
> Set!(T) set() {...}
> }
> 
> again, not as clean but, it could work.
> 
> I haven't tried this so it may not work.

I don't really care if the function implementation isn't very clean, as
long as it's clean where set literals are used. That's what you want
from a library.

I'll try it out and get back to you.

-- 
Michiel



More information about the Digitalmars-d mailing list