View source code
Display the source code in std/meta.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Module std.meta

Templates to manipulate template parameter sequences (also known as alias sequences).

Some operations on alias sequences are built into the language, such as S[i], which accesses the element at index i in the sequence. S[low .. high] returns a new alias sequence that is a slice of the old one.

For more information, see Compile-time Sequences.

Note: Several templates in this module use or operate on eponymous templates that take a single argument and evaluate to a boolean constant. Such templates are referred to as template predicates.

Category Templates
Building blocks Alias AliasSeq aliasSeqOf
Alias sequence filtering Erase EraseAll Filter NoDuplicates Stride
Alias sequence type hierarchy DerivedToFront MostDerived
Alias sequence transformation Repeat Replace ReplaceAll Reverse staticMap staticSort
Alias sequence searching allSatisfy anySatisfy staticIndexOf
Template predicates templateAnd templateNot templateOr staticIsSorted
Template instantiation ApplyLeft ApplyRight Instantiate

References

Based on ideas in Table 3.1 from Modern C++ Design, Andrei Alexandrescu (Addison-Wesley Professional, 2001)

Templates

NameDescription
ApplyLeft Partially applies Template by binding its first (left) or last (right) arguments to args.
ApplyRight Partially applies Template by binding its first (left) or last (right) arguments to args.
templateAnd Combines several template predicates using logical AND, i.e. constructs a new predicate which evaluates to true for a given input T if and only if all of the passed predicates are true for T.
templateNot Negates the passed template predicate.
templateOr Combines several template predicates using logical OR, i.e. constructs a new predicate which evaluates to true for a given input T if and only at least one of the passed predicates is true for T.

Manifest constants

NameTypeDescription
allSatisfy Tests whether all given items satisfy a template predicate, i.e. evaluates to F!(T[0]) && F!(T[1]) && ... && F!(T[$ - 1]).
anySatisfy Tests whether any given items satisfy a template predicate, i.e. evaluates to F!(T[0]) || F!(T[1]) || ... || F!(T[$ - 1]).
staticIndexOf Returns the index of the first occurrence of type T in the sequence of zero or more types TList. If not found, -1 is returned.
staticIsSorted Checks if an AliasSeq is sorted according to cmp.

Aliases

NameTypeDescription
Alias a Allows aliasing of any single symbol, type or compile-time expression.
AliasSeq TList Creates a sequence of zero or more aliases. This is most commonly used as template parameters or arguments.
aliasSeqOf AliasSeq!() Converts an input range range to an alias sequence.
DerivedToFront TList Returns an AliasSeq with the elements of TList sorted so that the most derived types come first.
Erase GenericErase!(T,TList) Returns an AliasSeq created from TList with the first occurrence, if any, of T removed.
EraseAll GenericEraseAll!(T,TList) Returns an AliasSeq created from TList with the all occurrences, if any, of T removed.
Filter AliasSeq!() Filters an AliasSeq using a template predicate. Returns an AliasSeq of the elements which satisfy the predicate.
Instantiate Template!Params Instantiates the given template with the given parameters.
MostDerived T Returns the type from TList that is the most derived from type T. If none are found, T is returned.
NoDuplicates AliasSeq!(fst,EraseAllN!(fst.length,fst,snd)) Returns an AliasSeq created from TList with the all duplicate types removed.
Repeat AliasSeq!() Creates an AliasSeq which repeats TList exactly n times.
Replace GenericReplace!(T,U,TList) Returns an AliasSeq created from TList with the first occurrence of type T, if found, replaced with type U.
ReplaceAll GenericReplaceAll!(T,U,TList) Returns an AliasSeq created from TList with all occurrences of type T, if found, replaced with type U.
Reverse TList Returns an AliasSeq created from TList with the order reversed.
staticMap AliasSeq!() Evaluates to AliasSeq!(F!(T[0]), F!(T[1]), ..., F!(T[$ - 1])).
staticSort Seq Sorts an AliasSeq using cmp.
Stride AliasSeq!() Selects a subset of Args by stepping with fixed stepSize over the sequence. A negative stepSize starts iteration with the last element.

Authors

Walter Bright, David Nadlinger

License

Boost License 1.0.