The constructs of CppML
are divided in into several smaller libraries, which are described below:
Library | Description |
---|---|
Algorithm |
Algorithms over parameter packs (e.g. Sort , ZipWith , etc.) |
Arithmetic |
Arithmetic operations on type-values (e.g. Greater , Not , etc.) |
Functional |
Manipulation of metafunctions (e.g. Curry , Map , etc.) |
Pack |
Manipulation of parameter packs (e.g. Drop , Get , etc.) |
TypeTraits |
Insights into types (e.g. IsSame , IsClass , etc.) |
Vocabulary |
Vocabulary types of CppML (e.g. ListT , Value , etc.) |
CppML is structured as follows:
- each library has an associated header
.hpp
and a directory of the same name in theCppML/
directory. For example, theAlgorithm
library has anAlgorithm.hpp
header located in theinclude/CppML
- every component of each library has a dedicated
.hpp
header inside the libraries associated directory. For example,Sort
, a component of theAlgorithm
library, has a header located atinclude/CppML/Algorithm/Sort.hpp
.
Thus, to use any component, you can either include its specific header (e.g. #include <CppML/Algorithm/Sort.hpp>
), or include its libraries header #include <CppML/Algorithm.hpp>
. Note that you may include all libraries at once using #include <CppML/CppML.hpp>
.
Find the algorithm of your interest in the table below. Each of them has it own reference page
, where you can find a specification of its structure, a definition of its metafunction type, and an example of use.
Construct | Description | Type of f in ::f >-> Pipe |
---|---|---|
AllOf |
Checks if a Predicate holds for all of Ts... . |
Ts... -> Bool<t> |
AnyOf |
Checks if a Predicate holds for any of Ts... . |
Ts... -> Bool<t> |
Contains |
Checks if Ts... contains T . |
Ts... -> Bool<t> |
CountIf |
Counts Ts... for which the Predicate holds. |
Ts... -> Bool<t> |
Filter |
Filters Ts... , for which the Predicate holds. |
Ts... -> Us... |
FilterIds |
Filters indexes of Ts... , for which the Predicate holds. |
Ts... -> Int<Is>... |
FindIdIf |
Index of Ts... for which the Predicate holds. |
Ts... -> Int<I> |
FindIdIfNot |
Index of Ts... for which the Predicate does not hold. |
Ts... -> Int<I> |
FindIf |
Element of Ts... for which the Predicate holds. |
Ts... -> T |
FindIfNot |
Element of Ts... for which the Predicate does not hold. |
Ts... -> T |
GroupBy |
Groups Ts... , given their image under By . |
Ts... -> ListT<Us...>... |
GroupIdsBy |
Groups indexes of Ts... , given their (T 's) image under By . |
Ts... -> ListT<Int<Is>...>... |
InclusiveScan |
Inclusive scan under the binary F . |
Ts... -> T0, F(T0, T1), ... |
MaxElement |
Get maximal element, given a Comparator . |
Ts... -> U |
NoneOf |
Checks if a Predicate holds for none of Ts... . |
Ts... -> Bool<t> |
Partition |
Partitions Ts... given a Predicate . |
Ts... -> ListT<Us...>... |
PartitionIds |
Partitions indexes of Ts... given a Predicate . |
Ts... -> ListT<Int<Is>...>... |
Pivot |
Pivots Ts... around the N -th element, making it the first. |
Ts... -> Us... |
Reduce |
Reduce Ts... , given an accumulator F . |
Init, Ts... -> U |
RemoveIdsIf |
Removes indexes of Ts... for which the Predicate holds. |
Ts... -> Us... |
RemoveIf |
Removes elements of Ts... for which the Predicate holds. |
Ts... -> Int<Is>... |
ReplaceIf |
Replace Ts... , for which the Predicate holds, by U . |
Ts... -> Us... |
Rotate |
Pivots Ts... in the range [First, Middle, Last) . |
Ts... -> Us... |
Sort |
Sorts Ts... , given a Comparator . |
Ts... -> Us... |
UniqueCompare |
Unique elements of Ts... , given a Comparator . |
Ts... -> Us... |
Unique |
Unique elements of Ts... . |
Ts... -> Us... |
ZipWith |
Zips two lists with a With template. |
Ts... -> With<Us...>... |
ZipWithVariadic |
Zips two lists with a variadic With template. |
Ts... -> With<Us...>... |
Find the construct of your interest in the table below. Each of them has it own reference page
, where you can find a specification of its structure, a definition of its metafunction type, and an example of use.
Construct | Description | Type of f in ::f >-> Pipe |
---|---|---|
Add |
Adds two Value s. |
Value<T, t>, Value<U, u> -> Value<V, t + u> |
Decrement |
Decrements a Value |
Value<t, T> -> Value<--t, T> |
Divide |
Divides two Value s. |
Value<T, t>, Value<U, u> -> Value<V, t / u> |
Equals |
Equality check for Values . |
Value<T, t>, Value<U, u> -> Bool<t> |
Greater |
Greater for Values . |
Value<T, t>, Value<U, u> -> Bool<t> |
Increment |
Increments a Value . |
Value<t, T> -> Value<++t, T> |
Less |
Less for Values . |
Value<T, t>, Value<U, u> -> Bool<t> |
Multiply |
Multiplies two Value s. |
Value<T, t>, Value<U, u> -> Value<V, t * u> |
Not |
Negates a Value . |
Bool<t> -> Bool< not t> |
Subtract |
Subtracts two Value s. |
Value<T, t>, Value<U, u> -> Value<V, t + u> |
Contains functional utilities (e.g. Map
). You can include any construct separately by CppML/Functional/<name>.hpp
, or include the entire header CppML/Functional.hpp
.
Find the construct of your interest in the table below. Each of them has it own reference page
, where you can find a specification of its structure, a definition of its metafunction type, and an example of use.
Construct | Description | Type of f in ::f >-> Pipe |
---|---|---|
Bind |
Metafunction with args bound to specific positions. | Ts... -> Us... |
BranchPipe |
Branches to one of two Pipes , given a Predicate . |
Ts... -> Ts... |
Compose |
Composition of metafunctions Fs... . |
Ts... -> F0(F1(...(Fn(Us...) |
Constant |
Metafunction that always forwards U . |
Ts... -> U |
Curry |
The Curry (from the left) operator | T0s... -> T1s... -> Us... |
CurryR |
The Curry (from the right) operator | T1s... -> T0s... -> Us... |
DelayedEval |
Delays an evaluation until compiler knows the arity. | Ts... -> Us... |
f |
Invokes the f alias of the metafunction F |
Ts... -> F::f<Ts...> |
F |
Lifts a template to a metafunction | Ts... -> Template<Ts...> |
fx |
Invokes the metafunction on Ts... |
Ts... -> Us... -> Us... |
Identity |
Identity metafunction. | T -> T |
IfElse |
Chooses between T and U . |
T, U -> V |
Map |
Maps Ts... by F . |
Ts... -> F(Ts)... |
Partial |
Partial evaluation of F on T0s... from the left |
T1... -> F(T0..., T1...) |
PartialR |
Partial Evaluation of F on T1s... from the right |
T0... -> F(T0..., T1...) |
Product |
Product of metafunctions Fs... |
Ts... -> Fs(Ts...)... |
ProductMap |
Product map of metafunctions Fs |
Ts... -> Fs(Ts)... |
ToList |
Wraps Ts... in an ListT |
Ts... -> ListT<Ts...> |
ToValue |
Invokes ::value on Ts... |
Value<Ts, ts>... -> ts... |
Unwrap |
Unwraps the template around Ts... |
Template<Ts...> -> Ts... |
Contains utilities for manipulating parameter packs. You can include any construct separately by CppML/Pack/<name>.hpp
, or include the entire header CppML/Pack.hpp
.
Find the construct of your interest in the table below. Each of them has it own reference page
, where you can find a specification of its structure, a definition of its metafunction type, and an example of use.
Construct | Description | Type of f in ::f >-> Pipe |
---|---|---|
Drop |
Drops first N of Ts... |
T1, ... Tn, Ts... -> Ts... |
Front |
Gets first element of Ts... |
T, Ts... -> T |
Get |
Gets N -th element of Ts... |
T1, ... Tn, Ts... -> Tn |
Head |
First N of Ts... |
T1, ... Tn, Ts... -> T1, ... Tn |
Insert |
Inserts U as N -th element of Ts... |
T1, ... Tn, Ts... -> T1, ... U, Tn, Ts... |
Length |
Length of Ts... |
Ts... -> Int<sizeof...(Ts) |
Concat |
Concatenates N templates T |
T<A0s...>... -> T<A0s..., A1s..., Ans...> |
PackExtractor |
Extracts N -th element. |
Int<N> -> T |
Prepend |
Prepends T to Ts... |
Ts... -> T, Ts... |
Range |
Pack of Int<I> in range |
From, To -> Int<From>..., Int<To - 1> |
Tail |
Last N of Ts... |
Ts..., T_{-N}, ... T_{-1} -> T_{-N}, ... T_{-1} |
Contains metafunctions that reason about the input types. You can include any construct separately by CppML/TypeTraits/<name>.hpp
, or include the entire header CppML/TypeTraits.hpp
.
Construct | Description | Type of f in ::f >-> Pipe |
---|---|---|
AlignOf |
Get alignment of T |
T -> Int<alignof(T)> |
IsClass |
Checks if T is a class type |
T -> Bool<t> |
IsConstructible |
Checks if T is constructable from Ts... |
T, Ts... -> Bool<t> |
IsConvertible |
Checks if T is convertible to U |
T, U -> Bool<t> |
IsSame |
Checks if T and U are the same type |
T, U -> Bool<t> |
IsSameTemplate |
Checks if T<Ts...> and U<Us...> are the same template |
T<Ts...>, U<Us...> -> Bool<t> |
IfValidOr |
F::f<Ts...> if it is not ill-formed, else U |
U, F, Ts... -> V |
IsValid |
Check if F invoked on Ts... is not ill-formed |
F, Ts... -> Bool<t> |
Contains the vocabulary constructs of CppML. You can include any construct separately by CppML/Vocabulary/<name>.hpp
, or include the entire header CppML/Vocabulary.hpp
.
Find the construct of your interest in the table below. Each of them has it own reference page
, where you can find a specification of its structure, a definition of its metafunction type, and an example of use.
Construct | Description |
---|---|
Value |
Represents a type-value |
List |
Represents a list of types |
None |
Represents the nothing type |