2 #ifndef UTOPIA_CORE_TYPETRAITS_HH
3 #define UTOPIA_CORE_TYPETRAITS_HH
15 #include <string_view>
17 #include <boost/hana/ext/std/tuple.hpp>
18 #include <boost/hana/for_each.hpp>
19 #include <boost/hana/tuple.hpp>
39 template <
typename T,
typename U = std::
void_t<> >
51 template <
typename T >
54 std::enable_if_t< std::is_pointer_v< T >, std::void_t<> > >
64 template <
typename T >
73 template <
typename T >
75 std::enable_if_t< std::is_array_v< T >, std::void_t<> > >
88 template <
typename T >
92 std::remove_cv_t< remove_pointer_t< std::remove_reference_t< T > > >;
96 template <
typename T >
103 template <
typename T >
111 template <
typename... Ts >
119 template<
typename... Ts>
120 struct is_string<
std::basic_string_view<Ts...>> :
public std::true_type{};
139 template <
typename T >
148 template <
typename T,
typename = std::
void_t<> >
159 template <
typename T >
165 template <
typename T >
174 template <
class T,
class U = std::
void_t<> >
180 template <
typename T >
189 template <
typename T >
191 std::void_t< std::enable_if_t<
192 is_iterable_v< remove_qualifier_t< T > > and
193 not is_string_v< remove_qualifier_t< T > >,
194 int > > > :
public std::true_type
209 template <
typename T,
typename = std::
void_t<> >
222 template <
typename T >
225 std::void_t< std::enable_if_t< is_container_v< T >, int >,
226 typename T::key_type,
227 typename T::key_compare > > : std::true_type
232 template <
typename T >
244 template <
typename T,
typename = std::
void_t<> >
257 template <
typename T >
260 std::void_t< std::enable_if_t< is_container_v< T >, int >,
261 typename T::key_type,
262 typename T::value_type,
263 typename T::hasher > > : std::true_type
268 template <
typename T >
279 template <
typename T,
typename = std::
void_t<> >
291 template <
typename T >
295 std::enable_if_t< not is_associative_container_v< T > and
296 not is_unordered_associative_container_v< T > and
298 int > > > : std::true_type
307 template <
typename T >
315 template <
typename T,
typename = std::
void_t<> >
325 template <
typename T >
328 std::void_t< std::enable_if_t<
329 is_linear_container_v< T > and
330 std::is_convertible_v< typename std::iterator_traits<
331 typename T::iterator >::iterator_category,
332 std::random_access_iterator_tag > > > >
338 template <
typename T >
347 template <
typename T,
typename U = std::
void_t<> >
356 template <
typename T >
363 template <
typename T >
372 template <
typename T,
typename U = std::
void_t<> >
381 template <
typename T >
388 template <
typename T >
396 template <
typename T,
typename U = std::
void_t<> >
407 template <
typename T >
410 std::void_t< std::enable_if_t< has_edge_descriptor_v< T > and
411 has_vertex_descriptor_v< T >,
412 int > > > : std::true_type
417 template <
typename T >
430 template <
typename T >
432 : std::integral_constant<
434 std::numeric_limits< std::size_t >::max() >
442 template <
typename T, std::
size_t N >
443 struct get_size<
std::array< T, N > > : std::integral_constant< std::size_t, N >
448 template <
typename... Ts >
450 : std::integral_constant< std::size_t, sizeof...(Ts) >
455 template <
typename A,
typename B >
456 struct get_size<
std::pair< A, B > > : std::integral_constant< std::size_t, 2 >
461 template <
typename... Ts >
463 : std::integral_constant< std::size_t, sizeof...(Ts) >
468 template < arma::uword N, arma::uword M >
470 : std::integral_constant< std::size_t, N * M >
475 template < arma::uword N, arma::uword M >
477 : std::integral_constant< std::size_t, N * M >
482 template < arma::uword N, arma::uword M >
484 : std::integral_constant< std::size_t, N * M >
489 template < arma::uword N, arma::uword M >
491 : std::integral_constant< std::size_t, N * M >
496 template < arma::uword N, arma::uword M >
498 : std::integral_constant< std::size_t, N * M >
503 template < arma::uword N, arma::uword M >
505 : std::integral_constant< std::size_t, N * M >
510 template < arma::uword N >
512 : std::integral_constant< std::size_t, N >
517 template < arma::uword N >
519 : std::integral_constant< std::size_t, N >
524 template < arma::uword N >
526 : std::integral_constant< std::size_t, N >
531 template < arma::uword N >
533 : std::integral_constant< std::size_t, N >
538 template < arma::uword N >
540 : std::integral_constant< std::size_t, N >
545 template < arma::uword N >
547 : std::integral_constant< std::size_t, N >
552 template < arma::uword N >
554 : std::integral_constant< std::size_t, N >
559 template < arma::uword N >
561 : std::integral_constant< std::size_t, N >
566 template < arma::uword N >
568 : std::integral_constant< std::size_t, N >
573 template < arma::uword N >
575 : std::integral_constant< std::size_t, N >
580 template < arma::uword N >
582 : std::integral_constant< std::size_t, N >
587 template < arma::uword N >
589 : std::integral_constant< std::size_t, N >
594 template <
typename T >
606 template <
typename T,
typename U = std::
void_t<> >
620 template <
typename T >
624 std::enable_if_t< get_size_v< T > !=
625 std::numeric_limits< std::size_t >::max() and
626 is_container_v< T > >,
627 int > > : std::true_type
632 template <
typename T >
643 template <
typename T, std::
size_t s >
655 template <
typename T >
668 template <
typename T >
674 template <
typename T >
683 template <
typename T,
typename X = std::
void_t<> >
687 static constexpr
bool value =
false;
696 template <
typename T >
699 std::void_t< std::enable_if_t< std::is_class_v< std::decay_t< T > >, T > > >
714 template <
typename U, U >
717 typedef char True[1];
718 typedef char False[2];
720 template <
typename S >
721 static constexpr True&
724 template <
typename S >
725 static constexpr False&
726 f(Check<
void (Fallback::*)(), &S::operator() >*);
729 static constexpr
bool value = (
sizeof(f< Derived >(
nullptr)) == 1);
733 template <
typename T >
static constexpr True & f(...)
static constexpr False & f(Check< void(Fallback::*)(), &S::operator()> *)
Check if a type T is callable, i.e., if it has.
Definition: type_traits.hh:685
static constexpr bool value
Definition: type_traits.hh:687
constexpr bool has_vertex_descriptor_v
Shorthand for has_vertex_descriptor<T>::value.
Definition: type_traits.hh:364
constexpr bool is_graph_v
Shorthand for is_graph<T>::value.
Definition: type_traits.hh:418
constexpr bool is_associative_container_v
Shorthand for is_associative_container<T>::value.
Definition: type_traits.hh:233
constexpr bool is_callable_v
Shorthand for is_callable<T>::value.
Definition: type_traits.hh:734
constexpr bool is_random_access_container_v
shorthand for is_linear_container<T>::value
Definition: type_traits.hh:339
constexpr bool is_container_v
Shorthand for 'is_container::value.
Definition: type_traits.hh:181
constexpr std::size_t get_size_v
Definition: type_traits.hh:595
typename remove_pointer< T >::type remove_pointer_t
Shorthand for 'typename remove_pointer<T>::type'.
Definition: type_traits.hh:65
constexpr bool has_static_size_v
Shorthand for has_static_size::value.
Definition: type_traits.hh:675
constexpr bool is_linear_container_v
Shorthand for is_linear_container<T>::value.
Definition: type_traits.hh:308
constexpr bool has_edge_descriptor_v
shothand for has_edge_descriptor<T>::value
Definition: type_traits.hh:389
constexpr bool is_unordered_associative_container_v
Shorthand for is_unordered_associative_container<T>::value.
Definition: type_traits.hh:269
constexpr bool is_iterable_v
shorthand for is_iterable<T>::value
Definition: type_traits.hh:166
typename remove_qualifier< T >::type remove_qualifier_t
Shorthand for 'typename remove_qualifier::value'.
Definition: type_traits.hh:97
constexpr bool is_array_like_v
Shorthand for is_array_like<T>::value.
Definition: type_traits.hh:633
constexpr bool is_string_v
Shorthand for 'is_string<T>::value'.
Definition: type_traits.hh:140
Definition: parallel.hh:235
Represent a type that does nothing and represents nothing, hence can be used in metaprogramming whene...
Definition: type_traits.hh:742
Return the size of a Type T containing other types at compile time. If no object for which an overloa...
Definition: type_traits.hh:438
Check if a type T has a edge descriptor.
Definition: type_traits.hh:374
Determine if type T is 'tuplelike'. This is not intended to be used explicitly, refer to 'has_static_...
Definition: type_traits.hh:645
Determine if type T is tuple_like, i.e., has a compile time constant size which is smaller than std::...
Definition: type_traits.hh:670
Check if a type T has a vertex descriptor.
Definition: type_traits.hh:349
Check if a given type is homogeneous and has a size which is a compile time constant....
Definition: type_traits.hh:608
Check if a type T is an associative container type, i.e. a container type T that defines T::key_type ...
Definition: type_traits.hh:211
Check if a type is a container type, which does not include string types.
Definition: type_traits.hh:176
Check if some type T is a graph by checking if it has edge - and vertex_descriptors.
Definition: type_traits.hh:398
Check if a type T is iterable, i.e., if it defines T::iterable.
Definition: type_traits.hh:150
Check if a type T is a linear container. A linear container for us is any type T that is a container ...
Definition: type_traits.hh:281
Check if a type T is a random access container, i.e., any container type T that has an iterator tagge...
Definition: type_traits.hh:317
Check if a type T is a string-like type, i.e. std::basic_string, const char*, char*,...
Definition: type_traits.hh:105
Check if a type T is an unordered associative container type, i.e. a container type T that defines T:...
Definition: type_traits.hh:246
typename remove_pointer< std::remove_all_extents_t< T > >::type type
Definition: type_traits.hh:78
typename remove_pointer< std::remove_pointer_t< T > >::type type
Definition: type_traits.hh:56
Helper function for removing pointer qualifiers from a type recursivly This is the recursion base cas...
Definition: type_traits.hh:41
T type
Definition: type_traits.hh:42
Function for removing the qualifiers from a type T. Qualifiers are 'const', 'volative',...
Definition: type_traits.hh:90
std::remove_cv_t< remove_pointer_t< std::remove_reference_t< T > > > type
Definition: type_traits.hh:92