ivutils
Loading...
Searching...
No Matches
CTList< Args > Class Template Reference

The compile time list. More...

#include <ctlist.h>

Public Types

using ToFixList = FixList< Args... >
 Converting CTList to the FixList. Essentially adds a bitset to declaration.
 
using Tuple = std::tuple< Args ... >
 Internal std::tuple exact type.
 
template<typename ArgType >
using PushBack = CTList< Args..., ArgType >
 Type of CTList with one more argument in the end.
 
template<int I>
using Get = typename std::tuple_element< I, Tuple >::type
 Type of the CTList item by position.
 
using PopBack = typename Remove< This >::Last
 Type of CTList without the last argument.
 
using Pop = typename Remove< This >::First
 Type of CTList without the first argument.
 
template<class Pattern >
using Map = ctlist::internal::MapCTList< Pattern, This >
 Maps every CTList element Arg to either Pattern::template Type<Arg> or Pattern::template Type<Arg, index> whichever is available.
 
template<template< typename > class FilterPattern>
using Filter = typename This::Map< IgnoreFiltered< FilterPattern > >
 Compile time filtration of the CTList contents.
 
template<template< typename, typename > class BinaryOperator>
using Reduce = typename ctlist::internal::CTListReduce< BinaryOperator, This >::Type
 Compile time Reduce.
 

Public Member Functions

constexpr CTList ()
 Default constructor assumes that all types in list also have default constructor.
 
constexpr CTList (const This &other)=default
 The copy constructor is created by default.
 
constexpr CTList (Args &&... args)
 Constructor with default types, which is needed to allow brace enclosed intialization for each entry.
 
template<typename ... CArgs, typename std::enable_if< std::is_constructible< Tuple, CArgs... >::value, int >::type disabler = 0>
constexpr CTList (CArgs &&... cargs)
 Constructor proxy for std::tuple.
 
constexpr operator Tuple () const
 The CTList may be explicitly converted to underlying tuple type.
 
constexpr operator Tuple & ()
 The CTList may be explicitly converted to reference to it's data.
 
constexpr operator const Tuple & () const
 The CTList may be explicitly converted to const reference to it's data.
 
template<int I>
const Get< I > & get () const
 Gets const reference to list item.
 
template<int I>
Get< I > & get ()
 Gets reference to list item.
 
template<typename T >
const T & get () const
 Gets const reference to list item by its type.
 
template<typename T >
T & get ()
 Gets const reference to list item by its type.
 
template<typename ... FArgs>
auto map (FArgs &&... fargs)
 Map List contents to another CTList Functions disabled for empty CTList.
 
template<typename ... FArgs>
auto map (FArgs &&... fargs) const
 Map List contents to another CTList.
 
template<typename ... FArgs>
auto map2array (FArgs &&... fargs)
 Calls a function for each CTList's item and store results in std::array.
 
template<typename ... FArgs>
auto map2array (FArgs &&... fargs) const
 Calls a function for each CTList's item and store results in std::array.
 
template<typename ... FArgs>
auto foreach (FArgs &&... fargs) const
 Calls a function for each CTList item except the case it is std::ignore.
 
template<typename ... FArgs>
const auto foreach (FArgs &&... fargs)
 Calls a function for each CTList item except the case it is std::ignore.
 
template<template< typename > class Filter>
auto filter ()
 Compile time part of the filter function.
 
template<template< typename > class Filter>
auto filter () const
 Compile time part of the filter function.
 
template<typename FilterFunc , typename ... Fargs>
FixList< typename std::add_lvalue_reference< Args >::type... > filter (FilterFunc &&filterf, Fargs &&... fargs)
 Runtime part of the filter function.
 
template<typename FilterFunc , typename ... Fargs>
FixList< typename std::add_lvalue_reference_t< std::add_const_t< Args > >... > filter (FilterFunc &&filterf, Fargs &&... fargs) const
 Runtime part of the filter function.
 
template<template< typename > class Filter, typename ... Fargs>
auto filter (Fargs &&... fargs)
 Combines the compile time and runtime filter together.
 
template<template< typename > class Filter, typename ... Fargs>
auto filter (Fargs &&... fargs) const
 Combines the compile time and runtime filter together.
 
auto pop_back ()
 METHOD DOESN'T COPY DATA List contents without the last element.
 
auto pop ()
 METHOD DOESN'T COPY DATA List contents without the first element.
 

Static Public Member Functions

static constexpr int size ()
 Length of CTList.
 
template<typename T >
static constexpr int Count ()
 Number of items of a certain type in CTList.
 
template<typename T >
static constexpr bool Contains ()
 Checks if a type is in the list.
 
template<typename T >
static constexpr int Index ()
 Calculates the index of a type.
 
template<typename ... FArgs>
static auto static_map2array (FArgs &&... fargs)
 Calls a function for each CTList's item type which is not marked inactive in the provided bitset and store results in std::array.
 
template<typename ... FArgs>
static auto static_foreach (FArgs &&... fargs)
 Calls a function for each CTList item which is not marked inactive for the provided bitset.
 
template<int I>
static bool static_initialized (int fix_val)
 Check if the item for corresponding index is active in provided bitset.
 
template<typename T >
static bool static_initialized (int fix_val)
 Check if the item for corresponding type is active in provided bitset.
 

Static Public Attributes

static constexpr unsigned long long full_mask = (1<<This::size())-1
 the bitset value corresponiding to the list with every element enabled.
 

Detailed Description

template<typename ... Args>
class CTList< Args >

The compile time list.

It uses a tuple<Args...> as an internal runtime container.

Template Parameters
...Argsare the types contained in CTList .

Member Typedef Documentation

◆ Filter

template<typename ... Args>
template<template< typename > class FilterPattern>
using CTList< Args >::Filter = typename This::Map<IgnoreFiltered<FilterPattern> >

Compile time filtration of the CTList contents.

It substitutes all filtered out types by decltype(std::ignore) which is ignored by most of runtime calls.

Template Parameters
FilterPattern<Item>is a template parametrized with a typename Item. It contains a static constexpr bool value which is true if Item shouldn't be filtered and false otherwise.

◆ Get

template<typename ... Args>
template<int I>
using CTList< Args >::Get = typename std::tuple_element<I, Tuple>::type

Type of the CTList item by position.

Template Parameters
Iis the item position index.

◆ Map

template<typename ... Args>
template<class Pattern >
using CTList< Args >::Map = ctlist::internal::MapCTList<Pattern, This>

Maps every CTList element Arg to either Pattern::template Type<Arg> or Pattern::template Type<Arg, index> whichever is available.

The result is CTList containing the transformation images.

Template Parameters
Patternis a class with internal template Type describing the transformation.

◆ PushBack

template<typename ... Args>
template<typename ArgType >
using CTList< Args >::PushBack = CTList<Args..., ArgType>

Type of CTList with one more argument in the end.

Template Parameters
ArgTypetype of the new element.

◆ Reduce

template<typename ... Args>
template<template< typename, typename > class BinaryOperator>
using CTList< Args >::Reduce = typename ctlist::internal::CTListReduce<BinaryOperator, This>::Type

Compile time Reduce.

If the CTList contains only one item Reduce returns its type. Empty CTList doesn't have Reduce member.

Template Parameters
BinaryOperator<Type1,Type2>declares the operation on types. It contains a result type BinaryOperator<Type1,Type2>::Type.

Constructor & Destructor Documentation

◆ CTList() [1/4]

template<typename ... Args>
constexpr CTList< Args >::CTList ( )
inlineconstexpr

Default constructor assumes that all types in list also have default constructor.

In other cases different constructor should be used.

◆ CTList() [2/4]

template<typename ... Args>
constexpr CTList< Args >::CTList ( const This other)
constexprdefault

The copy constructor is created by default.

This constructor would be created anyways, but it's important to know there is a copy constructor here.

◆ CTList() [3/4]

template<typename ... Args>
constexpr CTList< Args >::CTList ( Args &&...  args)
inlineconstexpr

Constructor with default types, which is needed to allow brace enclosed intialization for each entry.

For example CTList<Arg1, Arg2> test_list({intializer_for_Arg1}, {intializer_for_Arg2}).

◆ CTList() [4/4]

template<typename ... Args>
template<typename ... CArgs, typename std::enable_if< std::is_constructible< Tuple, CArgs... >::value, int >::type disabler = 0>
constexpr CTList< Args >::CTList ( CArgs &&...  cargs)
inlineconstexpr

Constructor proxy for std::tuple.

Disabled if the arguments can't construct a tuple. It works for all the cases which are not covered by previous three constructors. For example intialization with tuple (lvalue or rvalue) is handled by it.

Member Function Documentation

◆ Contains()

template<typename ... Args>
template<typename T >
static constexpr bool CTList< Args >::Contains ( )
inlinestaticconstexpr

Checks if a type is in the list.

Template Parameters
Tis the type to check.
Returns
compile time bool check result.

◆ Count()

template<typename ... Args>
template<typename T >
static constexpr int CTList< Args >::Count ( )
inlinestaticconstexpr

Number of items of a certain type in CTList.

Template Parameters
Tis the type to query.
Returns
Number of items of type T.

◆ filter() [1/6]

template<typename ... Args>
template<template< typename > class Filter>
auto CTList< Args >::filter ( )
inline

Compile time part of the filter function.

Function is disabled for empty CTList.

Template Parameters
Filter<Item>is the filter pattern. It is the same type of pattern as in Filter.
Returns
CTList of reference to items with filterd out items replaced with std::ignore.

◆ filter() [2/6]

template<typename ... Args>
template<template< typename > class Filter>
auto CTList< Args >::filter ( ) const
inline

Compile time part of the filter function.

This is the constant version of the function. Function is disabled for empty CTList.

Template Parameters
Filter<Item>is the filter pattern. It is the same type of pattern as in Filter.
Returns
CTList of reference to items with filterd out items replaced with std::ignore.

◆ filter() [3/6]

template<typename ... Args>
template<template< typename > class Filter, typename ... Fargs>
auto CTList< Args >::filter ( Fargs &&...  fargs)
inline

Combines the compile time and runtime filter together.

Function is disabled for empty CTList.

Template Parameters
Filter<Item>is the template argument for compile time filter
Parameters
fargsare the arguments foe runtime part of the filter
Returns
FixList with all the items referenced or substituted by std::ignore in compile time filtering and filtered out items marked inactive.

◆ filter() [4/6]

template<typename ... Args>
template<template< typename > class Filter, typename ... Fargs>
auto CTList< Args >::filter ( Fargs &&...  fargs) const
inline

Combines the compile time and runtime filter together.

Const CTList version. Function is disabled for empty CTList.

Template Parameters
Filter<Item>is the template argument for compile time filter
Parameters
fargsare the arguments foe runtime part of the filter
Returns
FixList with all the items referenced or substituted by std::ignore in compile time filtering and filtered out items marked inactive.

◆ filter() [5/6]

template<typename ... Args>
template<typename FilterFunc , typename ... Fargs>
FixList< typename std::add_lvalue_reference< Args >::type... > CTList< Args >::filter ( FilterFunc &&  filterf,
Fargs &&...  fargs 
)
inline

Runtime part of the filter function.

Function is disabled for empty CTList.

Template Parameters
FilterFunctype if the function, expected to be deduced automatically.
Fargstypes of additional function arguments, expected to be deduced automatically.
Parameters
filterfis the filter function object which should return bool and takes one of the following
  • an item and the rest of the fargs as arguments
  • an index and corresponding item and fargs as arguments
  • an index and corresponding dereferenced item type as template arguments and item with fargs as arguments
fargsadditional arguments which are passed to the filter function as is
Returns
FixList with all the items referenced and filtered out items marked inactive.

◆ filter() [6/6]

template<typename ... Args>
template<typename FilterFunc , typename ... Fargs>
FixList< typename std::add_lvalue_reference_t< std::add_const_t< Args > >... > CTList< Args >::filter ( FilterFunc &&  filterf,
Fargs &&...  fargs 
) const
inline

Runtime part of the filter function.

Version of the function for const CTList. Function is disabled for empty CTList.

Template Parameters
FilterFunctype if the function, expected to be deduced automatically.
Fargstypes of additional function arguments, expected to be deduced automatically.
Parameters
filterfis the filter function object which should return bool and takes one of the following
  • an item and the rest of the fargs as arguments
  • an index and corresponding item and fargs as arguments
  • an index and corresponding dereferenced item type as template arguments and item with fargs as arguments
fargsadditional arguments which are passed to the filter function as is
Returns
FixList with all the items referenced and filtered out items marked inactive.

◆ foreach() [1/2]

template<typename ... Args>
template<typename ... FArgs>
const auto CTList< Args >::foreach ( FArgs &&...  fargs)
inline

Calls a function for each CTList item except the case it is std::ignore.

The foreach function doesn't return anything.

Template Parameters
FArgstypes of arguments, should be deduced automatically.
Parameters
fargsarguments list passed to a function. The first one should be a function which returns void and takes one of the following
  • an item and the rest of the fargs as arguments
  • an index and corresponding item and the rest of the fargs as arguments
  • an index and corresponding dereferenced item type as template arguments and item with the rest of fargs as arguments

◆ foreach() [2/2]

template<typename ... Args>
template<typename ... FArgs>
auto CTList< Args >::foreach ( FArgs &&...  fargs) const
inline

Calls a function for each CTList item except the case it is std::ignore.

This is version of a function for const CTList. The foreach function doesn't return anything.

Template Parameters
FArgstypes of arguments, should be deduced automatically.
Parameters
fargsarguments list passed to a function. The first one should be a function which returns void and takes one of the following
  • an item and the rest of the fargs as arguments
  • an index and corresponding item and the rest of the fargs as arguments
  • an index and corresponding dereferenced item type as template arguments and item with the rest of fargs as arguments

◆ get() [1/4]

template<typename ... Args>
template<int I>
Get< I > & CTList< Args >::get ( )
inline

Gets reference to list item.

Template Parameters
Iis the item index. Function should not compile if I is beyond list range. In that case it would report tuple index out of range.
Returns
The list I-th item.

◆ get() [2/4]

template<typename ... Args>
template<typename T >
T & CTList< Args >::get ( )
inline

Gets const reference to list item by its type.

Function should not compile if the type is not in list or if there is multiple items of the type in the list. In the first case it would report tuple index out of range,

Template Parameters
Tis the item Type.
Returns
The list item of type T.

◆ get() [3/4]

template<typename ... Args>
template<int I>
const Get< I > & CTList< Args >::get ( ) const
inline

Gets const reference to list item.

Template Parameters
Iis the item index. Function should not compile if I is beyond list range. In that case it would report tuple index out of range.
Returns
The list I-th item.

◆ get() [4/4]

template<typename ... Args>
template<typename T >
const T & CTList< Args >::get ( ) const
inline

Gets const reference to list item by its type.

Function should not compile if the type is not in list or if there is multiple items of the type in the list. In the first case it would report tuple index out of range,

Template Parameters
Tis the item Type.
Returns
The list item of type T.

◆ Index()

template<typename ... Args>
template<typename T >
static constexpr int CTList< Args >::Index ( )
inlinestaticconstexpr

Calculates the index of a type.

Fails to compile if there is more than one item of the type

Template Parameters
Tis the type we want index for.
Returns
index of type T or -1 if it's not found as compile time int.

◆ map() [1/2]

template<typename ... Args>
template<typename ... FArgs>
auto CTList< Args >::map ( FArgs &&...  fargs)
inline

Map List contents to another CTList Functions disabled for empty CTList.

Template Parameters
FArgstypes of fargs, should be deduced automatically.
Parameters
fargsis the list of arguments. First one is a function (callable object) which has a call opetor which can take one of the following
  • an item and the rest of the fargs as arguments
  • an index and corresponding item and the rest of the fargs as arguments
  • an index and corresponding item type as template arguments and item with the rest of fargs as arguments and returns a map image
Returns
CTList with mapped items

◆ map() [2/2]

template<typename ... Args>
template<typename ... FArgs>
auto CTList< Args >::map ( FArgs &&...  fargs) const
inline

Map List contents to another CTList.

This is the version of the function for const CTList. Functions disabled for empty CTList.

Template Parameters
FArgstypes of fargs, should be deduced automatically.
Parameters
fargsis the list of arguments. First one is a function (callable object) which has a call opetor which can take one of the following
  • an item and the rest of the fargs as arguments
  • an index and corresponding item and the rest of the fargs as arguments
  • an index and corresponding item type as template arguments and item with the rest of fargs as arguments and returns a map image
Returns
CTList with mapped items

◆ map2array() [1/2]

template<typename ... Args>
template<typename ... FArgs>
auto CTList< Args >::map2array ( FArgs &&...  fargs)
inline

Calls a function for each CTList's item and store results in std::array.

Function is disabled for empty CTList.

Template Parameters
FArgstypes of arguments, should be deduced automatically.
Parameters
fargsfunction arguments list. The first argument must be a fallback value, which would be returned in case std::ignore appeared in the list. The second argument is a function (callable object) which has a call operator which can take one of the following
  • an item and the rest of the fargs as arguments
  • an index and corresponding item and the rest of the fargs as arguments
  • an index and corresponding item type as template arguments and item with the rest of fargs as arguments
Returns
std::array of fallback types with the same length as the CTList.

◆ map2array() [2/2]

template<typename ... Args>
template<typename ... FArgs>
auto CTList< Args >::map2array ( FArgs &&...  fargs) const
inline

Calls a function for each CTList's item and store results in std::array.

This is constant CTList version of the function. Function is disabled for empty CTList.

Template Parameters
FArgstypes of arguments, should be deduced automatically.
Parameters
fargsfunction arguments list. The first argument must be a fallback value, which would be returned in case std::ignore appeared in the list. The second argument is a function (callable object) which has a call operator which can take one of the following
  • an item and the rest of the fargs as arguments
  • an index and corresponding item and the rest of the fargs as arguments
  • an index and corresponding item type as template arguments and item with the rest of fargs as arguments
Returns
std::array of fallback types with the same length as the CTList.

◆ operator const Tuple &()

template<typename ... Args>
constexpr CTList< Args >::operator const Tuple & ( ) const
inlineexplicitconstexpr

The CTList may be explicitly converted to const reference to it's data.

This conversion doesn't copy data.

◆ operator Tuple()

template<typename ... Args>
constexpr CTList< Args >::operator Tuple ( ) const
inlineexplicitconstexpr

The CTList may be explicitly converted to underlying tuple type.

This conversion does copy data.

◆ operator Tuple &()

template<typename ... Args>
constexpr CTList< Args >::operator Tuple & ( )
inlineexplicitconstexpr

The CTList may be explicitly converted to reference to it's data.

This conversion doesn't copy data.

◆ pop()

template<typename ... Args>
auto CTList< Args >::pop ( )
inline

METHOD DOESN'T COPY DATA List contents without the first element.

Function is absent for empty CTList. Function returns reference to the same dataset.

Returns
CTList of references for every item except the first

◆ pop_back()

template<typename ... Args>
auto CTList< Args >::pop_back ( )
inline

METHOD DOESN'T COPY DATA List contents without the last element.

Function is absent for empty CTList. Function returns reference to the same dataset.

Returns
CTList of references for every item except the last.

◆ size()

template<typename ... Args>
static constexpr int CTList< Args >::size ( )
inlinestaticconstexpr

Length of CTList.

Returns
compile time int list length.

◆ static_foreach()

template<typename ... Args>
template<typename ... FArgs>
static auto CTList< Args >::static_foreach ( FArgs &&...  fargs)
inlinestatic

Calls a function for each CTList item which is not marked inactive for the provided bitset.

The foreach function doesn't return anything.

Template Parameters
FArgstypes of arguments, should be deduced automatically.
Parameters
fargsarguments list passed to a function. The firs one is the bitset marking active items passed as int. The second one should be a function which returns void and takes one of the following
  • Dereferenced item type as template argument and rest of the fargs as arguments
  • Index and corresponding dereferenced item type as template arguments and rest of the fargs as arguments

◆ static_initialized() [1/2]

template<typename ... Args>
template<int I>
static bool CTList< Args >::static_initialized ( int  fix_val)
inlinestatic

Check if the item for corresponding index is active in provided bitset.

Template Parameters
Ithe item's index
Parameters
fix_valbitset to check
Returns
true if the item is active in the provided bitset and false otherwise.

◆ static_initialized() [2/2]

template<typename ... Args>
template<typename T >
static bool CTList< Args >::static_initialized ( int  fix_val)
inlinestatic

Check if the item for corresponding type is active in provided bitset.

If there are multiple items of the type in the list function fails to compile.

Template Parameters
Tthe item's type
Parameters
fix_valbitset to check
Returns
true if the item is active in the provided bitset and false otherwise.

◆ static_map2array()

template<typename ... Args>
template<typename ... FArgs>
static auto CTList< Args >::static_map2array ( FArgs &&...  fargs)
inlinestatic

Calls a function for each CTList's item type which is not marked inactive in the provided bitset and store results in std::array.

Function is disabled for empty CTList.

Template Parameters
FArgstypes of arguments, should be deduced automatically.
Parameters
fargsfunction arguments list. The first argument must be a fallback value, which would be returned in case std::ignore appeared in the list. The second argument is the bitset (passed as int number). The third argument is a function (callable object) which has a call operator which can take one of the following
  • Dereferenced item type as template argument and rest of the fargs as arguments
  • Index and corresponding dereferenced item type as template arguments and rest of the fargs as arguments
Returns
std::array of fallback types with the same length as the CTList.

The documentation for this class was generated from the following file: