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 | AliasAliasSeqaliasSeqOf | 
| Alias sequence filtering | EraseEraseAllFilterNoDuplicatesStride | 
| Alias sequence type hierarchy | DerivedToFrontMostDerived | 
| Alias sequence transformation | RepeatReplaceReplaceAllReversestaticMapstaticSort | 
| Alias sequence searching | allSatisfyanySatisfystaticIndexOf | 
| Template predicates | templateAndtemplateNottemplateOrstaticIsSorted | 
| Template instantiation | ApplyLeftApplyRightInstantiate | 
References
Based on ideas in Table 3.1 from Modern C++ Design, Andrei Alexandrescu (Addison-Wesley Professional, 2001)
Templates
| Name | Description | 
|---|---|
| 
									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
| Name | Type | Description | 
|---|---|---|
| aliasSeqOf | Converts any foreach-iterable entity (e.g. an input range) to an alias sequence. | |
| staticIndexOf | Returns the index of the first occurrence of args[0]in the
 sequenceargs[1 .. $].argsmay be types or compile-time values.
 If not found,-1is returned. | |
| staticIsSorted | Checks if an AliasSeqis sorted according tocmp. | 
Aliases
| Name | Type | Description | 
|---|---|---|
| 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. | 
| allSatisfy | allSat!(F,T) | Tests whether all given items satisfy a template predicate, i.e. evaluates to F!(T[0]) && F!(T[1]) && ... && F!(T[$ - 1]). | 
| anySatisfy | anySat!(F,T) | Tests whether any given items satisfy a template predicate, i.e. evaluates to F!(T[0]) || F!(T[1]) || ... || F!(T[$ - 1]). | 
| DerivedToFront | staticSort!(cmp,TList) | Returns an AliasSeqwith the elements of TList sorted so that the most
 derived types come first. | 
| Erase | args[1..__dollar] | Returns an AliasSeqcreated fromargs[1 .. $]with the first occurrence,
 if any, ofargs[0]removed. | 
| EraseAll | AliasSeq!() | Returns an AliasSeqcreated fromargs[1 .. $]with all occurrences,
 if any, ofargs[0]removed. | 
| Filter | AliasSeq!() | Filters an AliasSequsing a template predicate. Returns anAliasSeqof the elements which satisfy the predicate. | 
| Instantiate | Template!Params | Instantiates the given template with the given parameters. | 
| MostDerived | T | Returns the type from TListthat is the most derived from typeT.
 If no such type is found,Tis returned. | 
| NoDuplicates | AliasSeq!() | Returns an AliasSeqcreated fromargswith all duplicate
 types removed. | 
| Repeat | AliasSeq!() | Creates an AliasSeqwhich repeatsitemsexactlyntimes. | 
| Replace | GenericReplace!(T,U,TList) | Returns an AliasSeqcreated from TList with the first occurrence
 of T, if found, replaced with U. | 
| ReplaceAll | AliasSeq!() | Returns an AliasSeqcreated fromargs[2 .. $]with all occurrences
 ofargs[0], if any, replaced withargs[1]. | 
| Reverse | AliasSeq!() | Returns an AliasSeqcreated fromargswith the order reversed. | 
| staticMap | AliasSeq!() | Evaluates to AliasSeq!(fun!(args[0]), fun!(args[1]), ..., fun!(args[$ - 1])). | 
| staticSort | items | Sorts an AliasSequsingcmp. | 
| Stride | AliasSeq!() | Selects a subset of Argsby stepping with fixedstepSizeover the sequence.
A negativestepSizestarts iteration with the last element. | 
Authors
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.