Template metaprogramming library originally spun off from CppOrderBook project.
- non_repeating_combinations: provides functionality that generates all non-repeating combinations of a specified size for all integers from 1 through n. All combinations are encapsulated consecutively in a single std::integer_sequence which can than be split and consumed.
- param_pack: provides class templates that can wrap type and non-type parameter packs which can then be accessed and manipulated much like an array-like data structure. Provide interfaces for monoidal, functorial, applicative-functorial and monadic access
- function_signature: can deduce the return type and the argument type from an instance of a function-like type
- type_pack_check: provides functionality to enforce certain properties across multiple types at compile time using either a single monoidal class template or two different templates.
- helpers: short collection that provides functionality to other components
- found in namespace
helpersin filehelpers.hpp
template <typename T>
concept constexpr_bool_value
- C++20 concept to determine whether a type has as static constexpr member of type bool named value
template<template <typename...> class Class_Template, typename type>
constexpr inline bool specializes_Class_Template_v
- variable template to determine wheter a specific class template accepting only type parameters is specialized by a specific type
template<template <auto...> class Class_Template, typename type>
constexpr inline bool specializes_Class_Template_nt_v
- variable template to determine wheter a specific class template accepting only non-type parameters is specialized by a specific type
template<template <typename T, T...> class Class_Template, typename type>
constexpr inline bool specializes_Class_Template_tnt_v
- variable template to determine wheter a specific class template accepting a single type parameter
Tand a pack of non-type parameters of typeTis specialized by a specific type
- found in namespace
non_rep_combinationsin filenon_rep_combinations.hpp
template <size_t n, size_t r>
using non_rep_combinations_t
- computes all non-repeating combinations of length
rintegers 1 throughn - generates a specialization of
std::integer_sequencewith typesize_tcontaining all combinations in one conseqcutive sequence which can then be broken down into the individual combinations
template <size_t n, size_t r>
using non_rep_combinations_t
- computes all non-repeating combinations of length
rintegers 0 throughn- 1 - generates a specialization of
std::integer_sequencewith typesize_tcontaining all combinations in one conseqcutive sequence which can then be broken down into the individual combinations - can be used to compute combinations of indices for data structures with
nentries, e.g. during compile time checks
- found in namespace
param_packin fileparam_pack.hpp
template <size_t i, typename... Ts>
using pack_index_t
- type alias template to extract the i-th type in type parameter pack
Ts
template <size_t i, auto... vs>
constexpr inline auto pack_index_v
- variable template to extract the i-th in non-type parameter pack
vs
template<auto... is>
constexpr inline bool single_type_nt_pack_v
- variable template to determine whether all values in non-type parameter pack
isare of the same type
template <auto... is>
using pack_type_t
- type alias template to extract the type of of a non-type paramter pack
is - requires that all values of
isare of the same type (i.e.single_type_nt_pack_v<is...> == true)
template<auto... vals>
using non_type_pack_t
- alias template that generates a
non_type_packfrom valuesvals
template<typename T>
using generate_non_type_pack_t
- generates a
non_type_packfrom a different typeT Tneeds to implement a template with either just a non-type argument pack or a single type as first argument denoting the the type of the non-type argument pack that follows
template<typename T>
constexpr inline bool non_type_pack_convertible_v
- variable template to determine whether type
Tcan be used to generate anon_type_packtype via thegenerate_non_type_pack_ttemplate
template<typename T>
using generate_type_pack_t
- generates a
type_pack_tfrom a different typeT Tneeds to implement a template with either just type arguments
template<typename T>
constexpr inline bool type_pack_convertible_v
- variable template to determine whether type
Tcan be used to generate atype_pack_ttype via thegenerate_type_pack_ttemplate
template<size_t n, auto i>
using repeat_n_times_t
- generates a
non_type_packcontainingntimes the valuei
template<typename T, T... vals>
struct non_type_pack
- class template that encapsulates non-type paramter pack consisting of values of type
T
- type alias for
T(i.e. type ofvals)
static constexpr size_t size
- number of values in
vals(i.e.sizeof...(vals))
template<typename append_pack>
using append_t
- type alias that appends different
non_type_packof values of typeTto this one - associative operation with 'empty' non-type-pack of same type
non_type_pack<T>as neutral element non_type_packis thus a monoid on a type level withappend_tas its monoid operation
template<size_t n>
using truncate_front_t
- type alias that removes the first
nvalues from thisnon_type_pack
template<size_t n>
using truncate_front_t
- type alias that removes the last
nvalues from thisnon_type_pack
template<size_t n>
using head_t
- type alias that yields a new
non_type_packcontaining the firstnvalues of this one
template<size_t n>
using tail_t
- type alias that yields a new
non_type_packcontaining the lastnvalues of this one
template<size_t i>
static constexpr T index_v
- variable template that extracts the i-th value from this
non_type_pack
template<template <auto...> class Class_Template>
using specialize_template_t
- class template that uses
valsas non-type template arguments toClass_Templateto generate a type
template<template <typename U, U...> class Class_Template>
using specialize_type_param_template_t
- class template that uses
typeas type argument andvalsas non-type template arguments toClass_Templateto generate a type
- member type,
non_type_packcontainingvalsin reverse order
template<auto callable>
using functor_map_t
- alias template taking a non-type argument
- argument needs to be constexpr callable, taking an argument of type
typeas argument functor_map_tappliescallableto all values contained invalsand yields a newnon_type_packcontaining the resultsnon_type_packis thus a functor on a type level
template<template<type...> class Class_Template, typename... Other_NTP_Packs>
using applicative_pure_t
- alias template taking a class template (which in turn takes non-type paramenter of type
type) and an arbitrary number of othernon_type_pack-types of same type and size as the one being used Class_Templateis then specialized with the n-th values in thisnon_type_packand all those containedOther_NTP_Packsfor n = 0 tosize - 1- all the specializations then need to contain a
constexprmember variablevalueof the same type - the resulting type is a new
non_type_packof typedecltype(value)and sizesize, containing all thevalues non_type_packis thus an applicative functor on a type level
template<template<T...> class Class_Template>
using monadic_bind_t
- takes a class template as an argument which takes a values of type
typeand generates anon_type_packtype - the generated types are then all concatenated to one
non_type_packtype non_type_packis thus a monad on a type level
template<auto fold_by, T init>
static constexpr T fold_v
- takes a value
fold_byas non-type arguments which in turn is callable with two values of typetype - takes an inital value
initand recursively "folds" all values contained invalsinto a single value
template<typename... Ts>
struct type_pack_t
- class template that encapsulates type paramter pack
static constexpr size_t size
- number of values in
Ts(i.e.sizeof...(Ts))
template<size_t i>
using index_t
- alias template that extracts the i-th type from this
type_pack_t
template<typename append_pack>
using append_t
- type alias that appends different
type_pack_tto this one - associative operation with 'empty' type-pack
type_pack_t<>as neutral element type_pack_tis thus a monoid on a type level withappend_tas its monoid operation
template<size_t n>
using truncate_front_t
- type alias that removes the first
nvalues from thistype_pack_t
template<size_t n>
using head_t
- type alias that yields a new
type_pack_tcontaining the firstnvalues of this one
template<size_t n>
using tail_t
- type alias that yields a new
type_pack_tcontaining the lastnvalues of this one
template<template <auto...> class Class_Template>
using specialize_template_t
- class template that uses
Tsas type template arguments toClass_Templateto generate a type
- member type,
type_pack_tcontainingTsin reverse order
template<template <typename...> class Class_Template><br> using functor_map_t`
- alias template taking a class template with a type parameter (or possibly more)
functor_map_tappliesClass_Templto all types contained inTsand yields a newtype_pack_tcontaining the resultstype_pack_tis thus a functor on a type level
template<template<typename...> class Class_Template, typename... Other_Type_Packs>
using applicative_pure_t
- alias template taking a class template (type paramenters) and an arbitrary number of other
type_pack_t-types of same size as the one being used Class_Templateis then specialized with the n-th type in thistype_pack_tand all those contained inOther_Type_Packsfor n = 0 tosize - 1- the resulting type is a new
type_pack_tof sizesize, containing all the specializations type_pack_tis thus an applicative functor on a type level
template<template <typename...> class Class_Template>
using monadic_bind_t
- takes a class template as an argument which has a type parameter generates a
type_pack_ttype - the generated types are then all concatenated to one
type_pack_ttype type_pack_tis thus a monad on a type level
template<typename NT_Pack, size_t len>
using split_t
- alias template with
NT_Packas a type paremeter, which is anon_type_packwith values of type size_t, andsize_tlenas a non-type parameter - generates nested
type_pack_twhose elements aretype_pack_ts of sizelencontaining types fromTsat indices specified innt_pack(and split into groups of sizelen)
template<template<typename...> class F, typename Init>
using fold_t
- takes a class template
Fwith two type parameters - takes an inital value
Initand recursively "folds" all types contained inTsinto a single type
template<template <typename...> class Templ, size_t order>
using apply_templ_to_nr_combs_t
- computes all non-repeating combinations of size
orderfromTs, uses each combiation to specializeTempland generates atype_pack_t-type containing all specializations
- found in namespace
function_signaturein file function_signature.hpp - deduces the return type and argument types of a function-like from an instance of that type
- piggybacks on
std::function, which can be specilized/constructed from any number of callable types - some credit goes to this article
template<auto f>
requires helpers::specializes_class_template_v<std::function, decltype(std::function(f))>
using ret_type_t
- deduces the return type of
f, providedstd::functioncan be constructed fromf
template<auto f>
requires helpers::specializes_class_template_v<std::function, decltype(std::function(f))>
using arg_types_t
- generates a specialization of
param_pack::type_pack_tcontaining all the argument types off, providedstd::functioncan be constructed fromf
- found in namespace
type_pack_tin filetype_pack_check.hpp - provides functionality to perform compile time checks over set of types
template<template<typename...> class Type_Handler, template<typename, typename> class Aggregator, size_t order, typename... Ts>
using checker_aggregator_check_t
- uses every non-repeating compination of length
orderfromTsto specialize templateType_Handlerand aggregates all specializations in a fold-like fashion using class templateAggregator Tscan be passed as a regualar type-parameter-pack or as a specialization ofparam_pack::type_pack_t
template<template<typename...> class Monoid_Templ, size_t order, typename... Ts>
using monoid_check_t = monoid_check<Monoid_Templ,order,Ts...>
- uses every non-repeating compination of length
orderfromTsto specialize templateMonoid_Templand then usesMonoid_Templto aggregate all specializations in a fold-like fashion - for
Monoid_Templto be able to be used in that way,param_pack::check_closure_property_v<Monoid_Templ, order, Ts...> == trueis required Tscan be passed as a regualar type-parameter-pack or as a specialization ofparam_pack::type_pack_t