Const Tuples

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 25 05:45:59 PDT 2014


On Friday, 25 April 2014 at 12:42:33 UTC, bearophile wrote:
> Dicebot:
>
>> Well, wrong :) std.typecons.Tuple IS a struct - 
>> https://github.com/D-Programming-Language/phobos/blob/master/std/typecons.d#L388
>
> Nope, that's just an implementation detail. They are two quite 
> different data structures. Example: slicing a tuple always has 
> a meaning, while slicing a struct is in general meaningless.
>
> Bye,
> bearophile

It was what you want it to be, not what it is :) Slicing a struct 
is absolutely routine thing as struct is just a user-defined 
aggregate type. std.typecons.Tuple is just a subset of all 
structs implementing specific behavior. It still acts as struct 
everywhere when applicable.

Don't confuse std.typecons.Tuple and built-in template argument 
lists. Latter are indeed special type system entities. Former is 
just a smart struct.


More information about the Digitalmars-d-learn mailing list