OGS
BaseLib::TMP::detail Namespace Reference

Functions

template<typename Pred , template< typename... > typename SomeListOfTypes>
constexpr List filter (Pred, SomeListOfTypes<> *)
 
template<typename Pred , template< typename... > typename SomeListOfTypes, typename Head , typename... Tail>
constexpr decltype(auto) filter (Pred pred, SomeListOfTypes< Head, Tail... > *)
 
template<template< typename... > typename List, typename Function , typename Head , typename... Tail>
constexpr decltype(auto) map_to_array (Function &&f, List< Head, Tail... > *)
 
template<template< typename... > typename List, typename Function >
constexpr std::array< std::nullptr_t, 0 > map_to_array (Function &&, List<> *)
 
template<template< typename... > typename List, typename Function , typename... Types>
void foreach (Function &&f, List< Types... > *)
 

Function Documentation

◆ filter() [1/2]

template<typename Pred , template< typename... > typename SomeListOfTypes, typename Head , typename... Tail>
decltype(auto) BaseLib::TMP::detail::filter ( Pred pred,
SomeListOfTypes< Head, Tail... > *  )
constexpr

Definition at line 56 of file TMP.h.

57{
58 constexpr auto tail_arg = static_cast<List<Tail...>*>(nullptr);
59 using TailFiltered = decltype(filter(pred, tail_arg));
60
61 using Result =
62 std::conditional_t<pred((Head*)nullptr),
63 Concat_t<List<Head>, TailFiltered>, TailFiltered>;
64
65 return Result{};
66}
constexpr List filter(Pred, SomeListOfTypes<> *)
Definition TMP.h:49
typename Concat< List1, List2 >::type Concat_t
Definition TMP.h:37
A list of types.
Definition TMP.h:43

References BaseLib::TMP::filter().

◆ filter() [2/2]

template<typename Pred , template< typename... > typename SomeListOfTypes>
List BaseLib::TMP::detail::filter ( Pred ,
SomeListOfTypes<> *  )
constexpr

Definition at line 49 of file TMP.h.

50{
51 return {};
52}

Referenced by BaseLib::TMP::filter().

◆ foreach()

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

Definition at line 144 of file TMP.h.

145{
146 (..., f((Types*)nullptr));
147}

Referenced by BaseLib::TMP::foreach().

◆ map_to_array() [1/2]

template<template< typename... > typename List, typename Function >
std::array< std::nullptr_t, 0 > BaseLib::TMP::detail::map_to_array ( Function && ,
List<> *  )
constexpr

Definition at line 120 of file TMP.h.

121{
122 return {};
123}

◆ map_to_array() [2/2]

template<template< typename... > typename List, typename Function , typename Head , typename... Tail>
decltype(auto) BaseLib::TMP::detail::map_to_array ( Function && f,
List< Head, Tail... > *  )
constexpr

Definition at line 109 of file TMP.h.

110{
111 using CommonType =
112 std::common_type_t<std::invoke_result_t<Function, Head*>,
113 std::invoke_result_t<Function, Tail*>...>;
114
115 return std::array<CommonType, 1 + sizeof...(Tail)>{f((Head*)nullptr),
116 f((Tail*)nullptr)...};
117}

Referenced by BaseLib::TMP::map_to_array().