Search code examples
d

Tuple vs TypeTuple in D


What is the difference between Tuple and TypeTuple? I've looked at sample code in the library, but they look similar. How do I decide which to use? and is there a good reason why Tuple is in std.typecons but TypeTuple is in std.typetuple?


Solution

  • A Tuple is a data type, consisting of a collection of fields that you specify.

    A TypeTuple is simply "a bunch of things" that the compiler knows about at compile time; it has no existence at run time.

    (Contrary to its name, a TypeTuple can hold pretty much anything -- not just types!)