OGS
BaseLib::TMP Namespace Reference

Namespaces

namespace  detail

Classes

struct  Concat
struct  Concat< List< Types1... >, List< Types2... > >
struct  List
 A list of types. More...
struct  Map
struct  Map< MapFromTypeToType, List< Types... > >

Typedefs

template<typename List1, typename List2>
using Concat_t = typename Concat<List1, List2>::type
template<template< typename > typename MapFromTypeToType, typename List>
using Map_t = typename Map<MapFromTypeToType, List>::type

Functions

template<typename List, typename Pred>
decltype(auto) filter (Pred pred)
template<typename List, typename Function>
constexpr decltype(auto) map_to_array (Function &&f)
template<typename List, typename Function>
void foreach (Function &&f)
template<typename List, typename Type>
constexpr bool contains ()
 Returns if Type is contained in the given List of types.

Typedef Documentation

◆ Concat_t

template<typename List1, typename List2>
using BaseLib::TMP::Concat_t = typename Concat<List1, List2>::type

Concatenates two lists of types.

Definition at line 30 of file TMP.h.

◆ Map_t

template<template< typename > typename MapFromTypeToType, typename List>
using BaseLib::TMP::Map_t = typename Map<MapFromTypeToType, List>::type

Turns a list of types into a list of different types via the provided type mapping.

Definition at line 95 of file TMP.h.

Function Documentation

◆ contains()

template<typename List, typename Type>
bool BaseLib::TMP::contains ( )
constexpr

Returns if Type is contained in the given List of types.

Definition at line 158 of file TMP.h.

159{
160 auto pred_is_same = []<typename OtherType>(OtherType*)
161 { return std::is_same_v<Type, OtherType>; };
162
163 return any_of(map_to_array<List>(pred_is_same));
164}
constexpr decltype(auto) map_to_array(Function &&f)
Definition TMP.h:127
constexpr bool any_of(List const &values)
Checks if any of the elements in the given list is true.
Definition Algorithm.h:286

References BaseLib::any_of(), and map_to_array().

Referenced by ProcessLib::detail::isElementEnabledImpl().

◆ filter()

template<typename List, typename Pred>
decltype(auto) BaseLib::TMP::filter ( Pred pred)

Filters the given list of types via the given predicate.

Keeps all elements for which pred is true.

The function signature of pred should be bool pred(Type*), where Type is a member of the given list of types.

Definition at line 71 of file TMP.h.

72{
73 return detail::filter(pred, static_cast<List*>(nullptr));
74}
constexpr List filter(Pred, SomeListOfTypes<> *)
Definition TMP.h:42
A list of types.
Definition TMP.h:36

References BaseLib::TMP::detail::filter().

Referenced by ProcessLib::BoundaryConditionAndSourceTerm::LocalAssemblerFactory< LocalAssemblerInterface, LocalAssemblerImplementation, GlobalDim, ConstructorArgs >::LocalAssemblerFactory(), ProcessLib::LocalAssemblerFactoryForDimGreaterEqualN< 1, LocalAssemblerInterface, LocalAssemblerImplementation, IntegrationMethodProvider, GlobalDim, ConstructorArgs... >::LocalAssemblerFactoryForDimGreaterEqualN(), ProcessLib::LocalAssemblerFactoryTaylorHood< 0, 0, LocalAssemblerInterface, LocalAssemblerImplementation, NumLib::DefaultIntegrationMethodProvider, GlobalDim, ConstructorArgs... >::LocalAssemblerFactoryTaylorHood(), ProcessLib::HeatTransportBHE::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataSoil, LocalAssemblerDataBHE, ConstructorArgs >::LocalDataInitializer(), ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, DisplacementDim, ConstructorArgs >::LocalDataInitializer(), ProcessLib::LIE::SmallDeformation::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, DisplacementDim, ConstructorArgs >::LocalDataInitializer(), BaseLib::TMP::detail::filter(), and ApplicationUtils::SolverByElementTypeRegistry< SolverInterface, SolverImplementationTplTpl >::initSolvers().

◆ foreach()

template<typename List, typename Function>
void BaseLib::TMP::foreach ( Function && f)

Applies the given function to a list of types.

The function signature should be void f(Type*), where Type is a member of the given list of types.

Definition at line 150 of file TMP.h.

151{
152 detail::foreach (std::forward<Function>(f), (List*)nullptr);
153}
void foreach(Function &&f, List< Types... > *)
Definition TMP.h:137

References BaseLib::TMP::detail::foreach().

Referenced by ProcessLib::BoundaryConditionAndSourceTerm::LocalAssemblerFactory< LocalAssemblerInterface, LocalAssemblerImplementation, GlobalDim, ConstructorArgs >::LocalAssemblerFactory(), ProcessLib::LocalAssemblerFactoryForDimGreaterEqualN< 1, LocalAssemblerInterface, LocalAssemblerImplementation, IntegrationMethodProvider, GlobalDim, ConstructorArgs... >::LocalAssemblerFactoryForDimGreaterEqualN(), ProcessLib::LocalAssemblerFactoryTaylorHood< 0, 0, LocalAssemblerInterface, LocalAssemblerImplementation, NumLib::DefaultIntegrationMethodProvider, GlobalDim, ConstructorArgs... >::LocalAssemblerFactoryTaylorHood(), ProcessLib::HeatTransportBHE::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataSoil, LocalAssemblerDataBHE, ConstructorArgs >::LocalDataInitializer(), ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, DisplacementDim, ConstructorArgs >::LocalDataInitializer(), ProcessLib::LIE::SmallDeformation::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, DisplacementDim, ConstructorArgs >::LocalDataInitializer(), ProcessLib::computeShapeMatrix(), and ApplicationUtils::SolverByElementTypeRegistry< SolverInterface, SolverImplementationTplTpl >::initSolvers().

◆ map_to_array()

template<typename List, typename Function>
decltype(auto) BaseLib::TMP::map_to_array ( Function && f)
constexpr

Applies the given function to a list of types returning the array of results.

The function signature should be ReturnType f(Type*), where Type is a member of the given list of types and ReturnType is the same for all overloads of f.

Definition at line 127 of file TMP.h.

128{
129 return detail::map_to_array(std::forward<Function>(f), (List*)nullptr);
130}
constexpr decltype(auto) map_to_array(Function &&f, List< Head, Tail... > *)
Definition TMP.h:102

References BaseLib::TMP::detail::map_to_array().

Referenced by contains().