www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - can i have a typed tuple?

reply dennis luehring <dl.soluz gmx.net> writes:
how can i define the type of an variadic template (tuple)?

item!(uint) test1;
item!(int) tes2t;
item!(double) test3;
int test4;

item_list!( test1, test2, test3, test4 );

item_list sould be an variadic template of items
so test4 should fail to compile (because its no item)

should i do a static if test in my item_list template or can
i limit the allowed type in the item_list interface?

"variadic list of this type"

ciao dennis
Aug 30 2007
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"dennis luehring" <dl.soluz gmx.net> wrote in message 
news:fb6dbm$2bgr$1 digitalmars.com...
 should i do a static if test in my item_list template or can
 i limit the allowed type in the item_list interface?

 "variadic list of this type"

You have to do a static if or static assert. Tuples are very permissive, and don't really offer any way to restrict what kinds of things can be passed to them.
Aug 30 2007
parent reply dennis luehring <dl.soluz gmx.net> writes:
Jarrett Billingsley Wrote:

 should i do a static if test in my item_list template or can
 i limit the allowed type in the item_list interface?
 "variadic list of this type"


 You have to do a static if or static assert.  Tuples are very permissive, 
 and don't really offer any way to restrict what kinds of things can be 
 passed to them. 

thx should tuples offer more restrictions (optional) ?
Aug 30 2007
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"dennis luehring" <dl.soluz gmx.net> wrote in message 
news:fb6ua0$3jm$1 digitalmars.com...

 should tuples offer more restrictions (optional) ?

I think you're entitled to whatever opinion you'd like.
Aug 30 2007