Tuples: AliasSeq

You will get to know about the use of AliasSeq in this lesson.

AliasSeq

AliasSeq is defined in the std.meta module. It is used for representing a concept that is normally used by the compiler but otherwise not available to the programmer as an entity, including a comma-separated list of values, types, and symbols (i.e., alias template arguments). The following are three examples of such lists:

  • Function argument list

  • Template argument list

  • Array literal element list

The following three lines of code are examples of these lists, respectively:

foo(1, "hello", 2.5); // function arguments 
auto o = Bar!(char, long)(); // template 
arguments auto a = [ 1, 2, 3, 4 ]; // array literal elements

Tuple takes advantage of AliasSeq when expanding its members.

The name AliasSeq comes from “alias sequence,” and it can contain types, values, and symbols.

AliasSeq and std.meta used to be called TypeTuple and std.typetuple, respectively.

This chapter includes AliasSeq examples that consist only of types or values independently. Examples of its use with both types and values will appear in the next chapter. AliasSeq is especially useful with variadic templates, which you will see in the next chapter as well.

AliasSeq consisting of values

The values that an AliasSeq represents are specified as its template arguments.

Let’s imagine a function that takes three parameters:

Get hands-on with 1200+ tech skills courses.