www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - tuples

reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
Is there currently any way to get something like

Tuple!(int,"i") t = tuple(5);

to work?
Oct 31 2009
next sibling parent reply zkp0s <gerar1995 gmail.com> writes:
Ellery Newcomer Wrote:

 Is there currently any way to get something like
 
 Tuple!(int,"i") t = tuple(5);
 
 to work?
Tuples are compile-time constructions. They are immutable. And btw the types do not coincide
Nov 02 2009
parent zkp0s <gerar1995 gmail.com> writes:
 Ellery Newcomer Wrote:
 
 Is there currently any way to get something like
 
 Tuple!(int,"i") t = tuple(5);
 
 to work?
Also they are used like: alias Tuple!(int,5) FOOBAR; FOOBAR [0] a_uint = FOOBAR[1]; //declares a_uint as an uint with value 5; http://www.digitalmars.com/d/2.0/tuple.html
Nov 02 2009
prev sibling parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
Ellery Newcomer wrote:
 Is there currently any way to get something like
 
 Tuple!(int,"i") t = tuple(5);
 
 to work?
Doh. It looks like Tuple!(int,"i") t = tuple!(int,"i")(5); should work, but I'm getting the following error /home/ellery/download/dmd2035/dmd2/linux/bin/../../src/phobos/std/typecons.d(514): Error: template std.typecons.tuple(T...) declaration T is already defined any ideas?
Nov 02 2009
parent zkp0s <wtf wtf.wtf> writes:
Ellery Newcomer Wrote:

 Ellery Newcomer wrote:
 Is there currently any way to get something like
 
 Tuple!(int,"i") t = tuple(5);
 
 to work?
Doh. It looks like Tuple!(int,"i") t = tuple!(int,"i")(5); should work, but I'm getting the following error /home/ellery/download/dmd2035/dmd2/linux/bin/../../src/phobos/std/typecons.d(514): Error: template std.typecons.tuple(T...) declaration T is already defined any ideas?
Ah that std.typecons tuple, not the variadic template tuple; I assume you are trying to initialize the tuple like
 Tuple!(int,"i") t = tuple!(5);
if it is not, what are you trying to do?
Nov 02 2009