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

Compile time list with a set of bit flags to enable or disable certain elements. More...

#include <ctlist.h>

Public Types

using ListType = CTList< Args... >
 the exact type of CTList stored inside the FixList.
 
using Tuple = typename ListType::Tuple
 the std::tuple type corresponding to ListType.
 
template<typename ArgType >
using PushBack = typename ListType::template PushBack< ArgType >::ToFixList
 Type of FixList with one more argument in the end.
 
template<int I>
using Get = typename ListType::template Get< I >
 Type of the FixList item by position.
 
using PopBack = typename ListType::PopBack::ToFixList
 Type of FixList without the last argument.
 
using Pop = typename ListType::Pop::ToFixList
 Type of FixList without the first argument.
 
template<class Pattern >
using Map = typename ListType::template Map< Pattern >::ToFixList
 Maps every FixList 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 ListType::template Filter< FilterPattern >::ToFixList
 Compile time filtration of the FixList contents.
 
template<template< typename, typename > class BinaryOperator>
using Reduce = typename ListType::template Reduce< BinaryOperator >::ToFixList
 Compile time Reduce.
 

Public Member Functions

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<int I, typename InitInterface , typename ... InitArgs>
auto init (InitInterface &&initializer, InitArgs &&... args) -> decltype(initializer(this->get< I >(), std::forward< InitArgs >(args)...))
 initialize the item by its index and set its bit up.
 
template<typename T , typename InitInterface , typename ... InitArgs>
auto init (InitInterface &&initializer, InitArgs &&... args) -> decltype(initializer(this->get< T >(), std::forward< InitArgs >(args)...))
 initialize the item by its type and set its bit up.
 
template<int I, typename InitInterface = InitMehtod, typename ... InitArgs>
decltype(auto) init (InitArgs &&... args)
 initialze item by index and set its bit up.
 
template<typename T , typename InitInterface = InitMehtod, typename ... InitArgs>
decltype(auto) init (InitArgs &&... args)
 initialze the item by its type and set its bit up.
 
template<typename T , typename ... FuncArgs>
std::array< T, This::size()> map2array (const T &fallback, FuncArgs &&... fargs)
 Calls a function for each FixList's item and store results in std::array.
 
template<typename ... FuncArgs>
void foreach (FuncArgs &&... fargs)
 Calls a function for each FixList item except std::ignore or the items with their bit set to false.
 
template<typename ... Fargs>
auto map (Fargs &&... fargs) -> typename decltype(data.map(std::forward< Fargs >(fargs)...))::ToFixList
 Map FixList contents to another FixList.
 
template<template< typename > class Filter>
auto filter () -> typename decltype(this->data.template filter< Filter >())::ToFixList
 Compile time part of the filter function.
 
template<typename ... Fargs>
auto filter (Fargs &&... fargs)
 Runtime part of the filter function.
 
template<template< typename > class Filter, typename ... Fargs>
auto filter (Fargs &&... fargs) -> decltype(this->filter< Filter >())
 Combines the compile time and runtime filter together.
 
void clear ()
 Sets all items to inactive and reinitialize the with default constructors.
 
const BitSetType & get_fix ()
 
template<int I>
bool initialized ()
 Check if the item for corresponding index is active.
 
template<typename T >
bool initialized ()
 Check if the item for corresponding type is active.
 

Static Public Member Functions

static constexpr int size ()
 Length of FixList.
 
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<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.
 
template<typename ... FArgs>
static auto static_map2array (FArgs &&... fargs)
 calls static_map2array for internal CTList.
 
template<typename ... FArgs>
static void static_foreach (FArgs &&... fargs)
 calls static_foreach for internal CTList.
 

Static Public Attributes

static constexpr unsigned long long full_mask = BitSetType::full
 the bitset value corresponiding to the list with every element enabled.
 

Detailed Description

template<typename ... Args>
class FixList< Args >

Compile time list with a set of bit flags to enable or disable certain elements.

Template Parameters
Argsthe list items.

Member Typedef Documentation

◆ Filter

template<typename ... Args>
template<template< typename > class FilterPattern>
using FixList< Args >::Filter = typename ListType::template Filter<FilterPattern>::ToFixList

Compile time filtration of the FixList contents.

Empty FixList doesn't have Map member type. 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 FixList< Args >::Get = typename ListType::template Get<I>

Type of the FixList item by position.

Template Parameters
Iis the item position index.

◆ Map

template<typename ... Args>
template<class Pattern >
using FixList< Args >::Map = typename ListType::template Map<Pattern>::ToFixList

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

The result is FixList containing the transformation images.

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

◆ PushBack

template<typename ... Args>
template<typename ArgType >
using FixList< Args >::PushBack = typename ListType::template PushBack<ArgType>::ToFixList

Type of FixList 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 FixList< Args >::Reduce = typename ListType::template Reduce<BinaryOperator>::ToFixList

Compile time Reduce.

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

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

Member Function Documentation

◆ Contains()

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

Checks if a type is in the list.

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

◆ filter() [1/3]

template<typename ... Args>
template<template< typename > class Filter>
auto FixList< Args >::filter ( ) -> typename decltype(this->data.template filter<Filter>())::ToFixList
inline

Compile time part of the filter function.

Function is disabled for empty FixList.

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

◆ filter() [2/3]

template<typename ... Args>
template<typename ... Fargs>
auto FixList< Args >::filter ( Fargs &&...  fargs)
inline

Runtime part of the filter function.

Function is disabled for empty FixList.

Template Parameters
Fargslist of template arguments. The first one is the function type. All the following are types of additional function arguments, expected to be deduced automatically. The filter function should return bool and take 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
Parameters
fargsthe filter function and its additional arguments which are passed to the filter function as is
Returns
FixList with all the items referenced and filtered out items marked inactive. The items originally marked as inactive remain the same. Fliter function for the is not called.

◆ filter() [3/3]

template<typename ... Args>
template<template< typename > class Filter, typename ... Fargs>
auto FixList< Args >::filter ( Fargs &&...  fargs) -> decltype(this->filter<Filter>())
inline

Combines the compile time and runtime filter together.

Function is disabled for empty FixList.

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. The items originally marked as inactive remain the same. Fliter function for the is not called.

◆ foreach()

template<typename ... Args>
template<typename ... FuncArgs>
void FixList< Args >::foreach ( FuncArgs &&...  fargs)
inline

Calls a function for each FixList item except std::ignore or the items with their bit set to false.

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 > & FixList< 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 & FixList< 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 > & FixList< 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 & FixList< 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.

◆ get_fix()

template<typename ... Args>
const BitSetType & FixList< Args >::get_fix ( )
inline
Returns
current bitset value

◆ Index()

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

Calculates the index of a type.

It is assumed that all types in the list are unique.

Template Parameters
Tis the type we want index for.
Returns
index of type T or -1 as compile time int.

◆ init() [1/4]

template<typename ... Args>
template<int I, typename InitInterface = InitMehtod, typename ... InitArgs>
decltype(auto) FixList< Args >::init ( InitArgs &&...  args)
inline

initialze item by index and set its bit up.

Template Parameters
Ithe index of the item
InitInterfacethe interface class with init method which initializes the item. InitInterface::init method takes the reference to the item as the first argument which is followed by args list.
InitArgstypes of arguments to initialize the item.
Parameters
argslist of the additional arguments to initialize the item.
See also
InitMehtod which calls item.init
CopyConstruct which copyconstructs the item

◆ init() [2/4]

template<typename ... Args>
template<typename T , typename InitInterface = InitMehtod, typename ... InitArgs>
decltype(auto) FixList< Args >::init ( InitArgs &&...  args)
inline

initialze the item by its type and set its bit up.

Template Parameters
Tthe type of the item
InitInterfacethe interface class with init method which initializes the item. InitInterface::init method takes the reference to the item as the first argument which is followed by args list.
InitArgstypes of arguments to initialize the item.
Parameters
argslist of the additional arguments to initialize the item.
See also
InitMehtod which calls item.init
CopyConstruct which copyconstructs the item

◆ init() [3/4]

template<typename ... Args>
template<int I, typename InitInterface , typename ... InitArgs>
auto FixList< Args >::init ( InitInterface &&  initializer,
InitArgs &&...  args 
) -> decltype(initializer(this->get<I>(), std::forward<InitArgs>(args)...))
inline

initialize the item by its index and set its bit up.

Template Parameters
Ithe index of the item
InitInterfacethe interface callable type which initializes the item.
InitArgstypes list for initialization arguments.
Parameters
initializercallable to initialize the item. It takes the reference to the item as the first argument, and all the args.
argslist of additional arguments for initalization function
Returns
the result of initializer call. It may be the value orsucces/error code.

◆ init() [4/4]

template<typename ... Args>
template<typename T , typename InitInterface , typename ... InitArgs>
auto FixList< Args >::init ( InitInterface &&  initializer,
InitArgs &&...  args 
) -> decltype(initializer(this->get<T>(), std::forward<InitArgs>(args)...))
inline

initialize the item by its type and set its bit up.

Template Parameters
Tthe type of item. Function will fail to compile if there are multiple items of the type T in the list.
InitInterfacethe interface callable type which initializes the item.
InitArgstypes list for initialization arguments.
Parameters
initializercallable to initialize the item. It takes the reference to the item as the first argument, and all the args.
argslist of additional arguments for initalization function
Returns
the result of initializer call. It may be the value orsucces/error code.

◆ initialized() [1/2]

template<typename ... Args>
template<int I>
bool FixList< Args >::initialized ( )
inline

Check if the item for corresponding index is active.

Template Parameters
Ithe item's index
Returns
true if the item is active and false otherwise.

◆ initialized() [2/2]

template<typename ... Args>
template<typename T >
bool FixList< Args >::initialized ( )
inline

Check if the item for corresponding type is active.

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

Template Parameters
Tthe item's type
Returns
true if the item is active and false otherwise.

◆ map()

template<typename ... Args>
template<typename ... Fargs>
auto FixList< Args >::map ( Fargs &&...  fargs) -> typename decltype(data.map(std::forward<Fargs>(fargs)...))::ToFixList
inline

Map FixList contents to another FixList.

The map function is applied even to the items with their bits set to false. Function is disabled for empty FixList.

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 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 and returns a map image
Returns
FixList with mapped items and the same bitset as in original one

◆ map2array()

template<typename ... Args>
template<typename T , typename ... FuncArgs>
std::array< T, This::size()> FixList< Args >::map2array ( const T &  fallback,
FuncArgs &&...  fargs 
)
inline

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

Function is disabled for empty FixLIst.

Template Parameters
FArgstypes of arguments, should be deduced automatically.
Parameters
fallbackvalue, which would be returned in case std::ignore appeared in the list or if the bit of the item is set to false.
fargsfunction arguments 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 FixList.

◆ size()

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

Length of FixList.

Returns
compile time int list length.

◆ static_foreach()

template<typename ... Args>
template<typename ... FArgs>
static void FixList< Args >::static_foreach ( FArgs &&...  fargs)
inlinestatic

calls static_foreach for internal CTList.

See also
CTList::static_foreach

◆ static_initialized() [1/2]

template<typename ... Args>
template<int I>
static bool FixList< 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 FixList< 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 FixList< Args >::static_map2array ( FArgs &&...  fargs)
inlinestatic

calls static_map2array for internal CTList.

See also
CTList::static_map2array

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