TypeTuple!(T...) vs Tuple!(T...)

rsw0x via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 2 11:52:10 PDT 2015


On Tuesday, 2 June 2015 at 14:07:20 UTC, Alex Parrill wrote:
> On Tuesday, 2 June 2015 at 08:10:27 UTC, rsw0x wrote:
>> exactly what is the difference here?
>>
>> I have a rather large CTFE-generated TypeTuple in one of my 
>> structs in my project, and I can seemingly replace it with a 
>> Tuple with absolutely zero differences... except I compile 
>> about 60-70% slower.
>>
>> The tuple page is even confusing me
>> http://dlang.org/tuple.html
>>
>>>A variable declared with a TypeTuple becomes an 
>>>ExpressionTuple:
>>>alias TL = Tuple!(int, long);
>>
>> is it using Tuple!(T...) and TypeTuple!(T...) interchangeably?
>
> Regular tuples are simply structs with a few methods like 
> opIndex. Ex. `Tuple!(A,B,C)` is mostly equivalent to `struct { 
> A _0; B _1; C _2; }`.
>
> TypeTuples (whose name is IMO a misnomer) are special 
> compile-time-only objects whose values are passed in the 
> template parameters and can be types, aliases, or literal 
> values. They aren't first-class types, and shouldn't be used as 
> data storage, but they do have some unique properties that make 
> them useful for metaprogramming.
> ...
I'm using a typetuple for data storage, if I replace it with a 
Tuple as I said in the OP, my program compiles 60-70% slower on 
all three compilers. But it seems to be working just fine as is, 
which is why I'm confused. I'm going to read Ali's links and 
maybe get a better understanding here.


More information about the Digitalmars-d-learn mailing list