32template <
typename T >
33struct _dependent_false : std::false_type
41template <
typename T >
42struct _default_template_guard
45 _dependent_false< T >::value,
46 "Default template matched, this implies unexpected usage of the template. Read the documentation of template." );
52template <
typename... Ts >
55 using types = typelist< Ts... >;
56 static constexpr std::size_t size =
sizeof...( Ts );
59template <
typename T >
62 static constexpr bool is_compatible =
false;
65template <
typename... Ts >
66struct typelist_traits< typelist< Ts... > >
68 static constexpr bool is_compatible =
true;
70 using types = typelist< Ts... >;
73template <
typename T >
74using typelist_traits_types =
typename typelist_traits< T >::types;
76template <
typename T >
77concept typelist_compatible = typelist_traits< T >::is_compatible;
83template <
typename T,
typename TL >
84struct index_of_t_or_const_t : _default_template_guard< T >
88template <
typename T, typelist_compatible TL >
89struct index_of_t_or_const_t< T, TL > : index_of_t_or_const_t< typelist_traits_types< T >, TL >
93template <
typename T >
94struct index_of_t_or_const_t< T, typelist<> >
96 static_assert( !std::same_as< T, T >,
"Type T is not present in the type list" );
99template <
typename T,
typename... Ts >
100struct index_of_t_or_const_t< T, typelist< T, Ts... > >
102 static constexpr std::size_t value = 0;
105template <
typename T,
typename... Ts >
106struct index_of_t_or_const_t< T, typelist< T const, Ts... > >
108 static constexpr std::size_t value = 0;
111template <
typename T,
typename U,
typename... Ts >
112struct index_of_t_or_const_t< T, typelist< U, Ts... > >
114 static constexpr std::size_t value =
115 1 + index_of_t_or_const_t< T, typelist< Ts... > >::value;
118template <
typename T,
typename TL >
119static constexpr std::size_t index_of_t_or_const_t_v = index_of_t_or_const_t< T, TL >::value;
125template < std::
size_t j,
typename TL >
126struct type_at : _default_template_guard< TL >
130template < std::
size_t j, typelist_compatible TL >
131struct type_at< j, TL > : type_at< j, typelist_traits_types< TL > >
135template < std::size_t j,
typename T,
typename... Ts >
136struct type_at< j, typelist< T, Ts... > >
138 using type =
typename type_at< j - 1, typelist< Ts... > >::type;
141template <
typename T,
typename... Ts >
142struct type_at< 0, typelist< T, Ts... > >
147template < std::
size_t j,
typename TL >
148using type_at_t =
typename type_at< j, TL >::type;
154template <
typename T,
typename TL >
155struct contains_type : _default_template_guard< T >
159template <
typename T, typelist_compatible TL >
160struct contains_type< T, TL > : contains_type< T, typelist_traits_types< TL > >
164template <
typename T,
typename... Ts >
165struct contains_type< T, typelist< Ts... > >
167 static constexpr bool value = ( std::same_as< T, Ts > || ... || false );
170template <
typename T,
typename TL >
171static constexpr bool contains_type_v = contains_type< T, TL >::value;
178template <
typename TL1,
typename TL2 >
179struct _unique_tl_impl : _default_template_guard< TL1 >
183template <
typename TL1, typelist_compatible TL2 >
184struct _unique_tl_impl< TL1, TL2 > : _unique_tl_impl< TL1, typelist_traits_types< TL2 > >
188template <
typename... Ts >
189struct _unique_tl_impl< typelist< Ts... >, typelist<> >
191 using type = typelist< Ts... >;
194template <
typename TL1,
typename T,
typename... Ts >
195 requires( contains_type_v< T, typelist< Ts... > > )
196struct _unique_tl_impl< TL1, typelist< T, Ts... > > : _unique_tl_impl< TL1, typelist< Ts... > >
200template <
typename... Us,
typename T,
typename... Ts >
201 requires( !contains_type_v< T, typelist< Ts... > > )
202struct _unique_tl_impl< typelist< Us... >, typelist< T, Ts... > >
203 : _unique_tl_impl< typelist< Us..., T >, typelist< Ts... > >
207template <
typename TL >
208using unique_typelist_t =
typename _unique_tl_impl< typelist<>, TL >::type;
215template <
typename TL,
typename... Ts >
216struct _flatten_impl : _default_template_guard< TL >
220template <
typename TL >
221struct _flatten_impl< TL >
226template <
typename... Us, typelist_compatible T,
typename... Ts >
227struct _flatten_impl< typelist< Us... >, T, Ts... >
228 : _flatten_impl< typelist< Us... >, typelist_traits_types< T >, Ts... >
232template <
typename... Us,
typename T,
typename... Ts >
233struct _flatten_impl< typelist< Us... >, T, Ts... > : _flatten_impl< typelist< Us..., T >, Ts... >
237template <
typename... Us,
typename... Ks,
typename... Ts >
238struct _flatten_impl< typelist< Us... >, typelist< Ks... >, Ts... >
239 : _flatten_impl< typelist< Us... >, Ks..., Ts... >
243template <
typename... Us,
typename... Ks,
typename... Ts >
244struct _flatten_impl< typelist< Us... >, typelist< Ks... > const, Ts... >
245 : _flatten_impl< typelist< Us... >, Ks const..., Ts... >
249template <
typename... Ts >
250using flatten_t =
typename _flatten_impl< typelist<>, Ts... >::type;
256template <
typename LH,
typename RH >
257struct is_subset : _default_template_guard< LH >
261template <
typename... Us,
typename RH >
262struct is_subset< typelist< Us... >, RH >
264 static constexpr bool value = ( contains_type_v< Us, RH > && ... );
267template <
typename... Us,
typename RH >
268struct is_subset< typelist< Us... > const, RH >
270 static constexpr bool value = ( contains_type_v< Us const, RH > && ... );
273template <
typename LH,
typename RH >
274static constexpr bool is_subset_v = is_subset< LH, RH >::value;
280template <
typename TL >
281struct any_is_const : _default_template_guard< TL >
285template < typelist_compatible TL >
286struct any_is_const< TL > : any_is_const< typelist_traits_types< TL > >
290template <
typename... Us >
291struct any_is_const< typelist< Us... > >
293 static constexpr bool value = ( std::is_const_v< Us > || ... );
296template <
typename TL >
297static constexpr bool any_is_const_v = any_is_const< TL >::value;
303template <
typename TL >
304struct all_is_const : _default_template_guard< TL >
308template < typelist_compatible TL >
309struct all_is_const< TL > : all_is_const< typelist_traits_types< TL > >
313template <
typename... Us >
314struct all_is_const< typelist< Us... > >
316 static constexpr bool value = ( std::is_const_v< Us > && ... );
319template <
typename TL >
320static constexpr bool all_is_const_v = all_is_const< TL >::value;
326template <
typename TL >
327struct none_is_const : _default_template_guard< TL >
331template < typelist_compatible TL >
332struct none_is_const< TL > : none_is_const< typelist_traits_types< TL > >
336template <
typename... Us >
337struct none_is_const< typelist< Us... > >
339 static constexpr bool value = !( std::is_const_v< Us > || ... );
342template <
typename TL >
343static constexpr bool none_is_const_v = none_is_const< TL >::value;
349template <
typename TL >
350struct all_nothrow_swappable : _default_template_guard< TL >
354template < typelist_compatible TL >
355struct all_nothrow_swappable< TL > : all_nothrow_swappable< typelist_traits_types< TL > >
359template <
typename... Us >
360struct all_nothrow_swappable< typelist< Us... > >
362 static constexpr bool value = ( std::is_nothrow_swappable_v< Us > && ... && true );
365template <
typename TL >
366static constexpr bool all_nothrow_swappable_v = all_nothrow_swappable< TL >::value;
372template <
typename TL >
373struct all_nothrow_move_constructible : _default_template_guard< TL >
377template < typelist_compatible TL >
378struct all_nothrow_move_constructible< TL >
379 : all_nothrow_move_constructible< typelist_traits_types< TL > >
383template <
typename... Us >
384struct all_nothrow_move_constructible< typelist< Us... > >
386 static constexpr bool value = ( std::is_nothrow_move_constructible_v< Us > && ... && true );
389template <
typename TL >
390static constexpr bool all_nothrow_move_constructible_v =
391 all_nothrow_move_constructible< TL >::value;
397template <
typename TL >
398struct all_nothrow_copy_constructible : _default_template_guard< TL >
402template < typelist_compatible TL >
403struct all_nothrow_copy_constructible< TL >
404 : all_nothrow_copy_constructible< typelist_traits_types< TL > >
408template <
typename... Us >
409struct all_nothrow_copy_constructible< typelist< Us... > >
411 static constexpr bool value = ( std::is_nothrow_copy_constructible_v< Us > && ... && true );
414template <
typename TL >
415static constexpr bool all_nothrow_copy_constructible_v =
416 all_nothrow_copy_constructible< TL >::value;
422template <
typename TL >
423struct all_nothrow_destructible : _default_template_guard< TL >
427template < typelist_compatible TL >
428struct all_nothrow_destructible< TL > : all_nothrow_destructible< typelist_traits_types< TL > >
432template <
typename... Us >
433struct all_nothrow_destructible< typelist< Us... > >
435 static constexpr bool value = ( std::is_nothrow_destructible_v< Us > && ... && true );
438template <
typename TL >
439static constexpr bool all_nothrow_destructible_v = all_nothrow_destructible< TL >::value;
444template <
typename U,
typename T >
445concept nothrow_three_way_comparable =
noexcept( std::declval< U >() <=> std::declval< T >() );
449template <
typename TL >
450struct all_nothrow_three_way_comparable : _default_template_guard< TL >
454template < typelist_compatible TL >
455struct all_nothrow_three_way_comparable< TL >
456 : all_nothrow_three_way_comparable< typelist_traits_types< TL > >
460template <
typename... Us >
461struct all_nothrow_three_way_comparable< typelist< Us... > >
463 static constexpr bool value = ( nothrow_three_way_comparable< Us, Us > && ... && true );
466template <
typename TL >
467static constexpr bool all_nothrow_three_way_comparable_v =
468 all_nothrow_three_way_comparable< TL >::value;
472template <
typename U,
typename T >
473concept nothrow_equality_comparable =
noexcept( std::declval< U >() == std::declval< T >() );
477template <
typename TL >
478struct all_nothrow_equality_comparable : _default_template_guard< TL >
482template < typelist_compatible TL >
483struct all_nothrow_equality_comparable< TL >
484 : all_nothrow_copy_constructible< typelist_traits_types< TL > >
488template <
typename... Us >
489struct all_nothrow_equality_comparable< typelist< Us... > >
491 static constexpr bool value = ( nothrow_equality_comparable< Us, Us > && ... && true );
494template <
typename TL >
495static constexpr bool all_nothrow_equality_comparable_v =
496 all_nothrow_equality_comparable< TL >::value;
503template <
typename TL, std::
size_t N,
typename Fac >
504struct _factory_result_types_impl : _default_template_guard< TL >
508template <
typename... Ts,
typename Fac >
509struct _factory_result_types_impl< typelist< Ts... >, 0, Fac >
511 using type = typelist< Ts... >;
514template <
typename... Ts, std::size_t N,
typename Fac >
515struct _factory_result_types_impl< typelist< Ts... >, N, Fac >
517 using n_type =
decltype( std::declval< Fac >().template operator()< N - 1 >() );
519 typename _factory_result_types_impl< typelist< Ts..., n_type >, N - 1, Fac >::type;
522template < std::
size_t N,
typename Fac >
523using factory_result_types_t =
typename _factory_result_types_impl< typelist<>, N, Fac >::type;
MIT License.
Definition: dispatch.h:32