1#ifndef ENTT_CORE_TYPE_TRAITS_HPP
2#define ENTT_CORE_TYPE_TRAITS_HPP
9#include "../config/config.h"
18template<std::
size_t N>
32template<std::
size_t N>
43template<
typename Type>
53template<
typename Type>
60template<
typename Type,
typename =
void>
61struct size_of: std::integral_constant<std::size_t, 0u> {};
64template<
typename Type>
65struct size_of<Type, std::void_t<decltype(sizeof(Type))>>
66 : std::integral_constant<std::size_t, sizeof(Type)> {};
72template<
typename Type>
80template<
typename Type,
typename>
88template<auto Value,
typename>
102template<
id_type Value>
109template<
typename... Type>
114 static constexpr auto size =
sizeof...(Type);
118template<std::
size_t,
typename>
127template<std::size_t Index,
typename First,
typename... Other>
136template<
typename First,
typename... Other>
147template<std::
size_t Index,
typename List>
151template<
typename,
typename>
160template<
typename Type,
typename First,
typename... Other>
173template<
typename Type,
typename... Other>
186template<
typename Type>
199template<
typename Type,
typename List>
208template<
typename... Type,
typename... Other>
230template<
typename... Type,
typename... Other,
typename... List>
240template<
typename... Type>
250template<
typename... List>
259template<
typename First,
typename... Other,
typename... Type>
261 : std::conditional_t<(std::is_same_v<First, Type> || ...), type_list_unique<type_list<Other...>, Type...>, type_list_unique<type_list<Other...>, Type..., First>> {};
263template<
typename... Type>
275template<
typename List>
278 using type =
typename internal::type_list_unique<List>::type;
285template<
typename List>
294template<
typename List,
typename Type>
302template<
typename... Type,
typename Other>
304 : std::bool_constant<(std::is_same_v<Type, Other> || ...)> {};
311template<
typename List,
typename Type>
323template<
typename... Type,
typename... Other>
333template<
typename... List>
337template<
typename,
template<
typename...>
class>
345template<
typename... Type,
template<
typename...>
class Op>
356template<
typename List,
template<
typename...>
class Op>
363template<
auto... Value>
368 static constexpr auto size =
sizeof...(Value);
372template<std::
size_t,
typename>
381template<std::size_t Index,
auto Value,
auto... Other>
390template<
auto Value,
auto... Other>
395 static constexpr auto value = Value;
403template<std::
size_t Index,
typename List>
411template<std::
size_t Index,
typename List>
415template<auto,
typename>
424template<
auto Value,
auto First,
auto... Other>
437template<
auto Value,
auto... Other>
463template<auto Value,
typename List>
472template<
auto... Value,
auto... Other>
494template<
auto... Value,
auto... Other,
typename... List>
504template<
auto... Value>
514template<
typename... List>
526template<
auto Value,
auto... Other>
529 using type = std::conditional_t<
530 ((Value == Other) || ...),
546template<
typename Type>
555template<
typename List, auto Value>
563template<
auto... Value,
auto Other>
565 : std::bool_constant<((Value == Other) || ...)> {};
572template<
typename List, auto Value>
584template<
auto... Value,
auto... Other>
597template<
typename... List>
601template<
typename,
typename>
610template<
typename Func,
template<
typename...>
class Tuple,
typename... Args>
611struct is_applicable<Func, Tuple<Args...>>: std::is_invocable<Func, Args...> {};
619template<
typename Func,
template<
typename...>
class Tuple,
typename... Args>
620struct is_applicable<Func, const Tuple<Args...>>: std::is_invocable<Func, Args...> {};
627template<
typename Func,
typename Args>
631template<
typename,
typename,
typename>
641template<
typename Ret,
typename Func,
typename... Args>
642struct is_applicable_r<Ret, Func, std::tuple<Args...>>: std::is_invocable_r<Ret, Func, Args...> {};
651template<
typename Ret,
typename Func,
typename Args>
659template<
typename Type,
typename =
void>
663template<
typename Type>
664struct is_complete<Type, std::void_t<decltype(sizeof(Type))>>: std::true_type {};
670template<
typename Type>
678template<
typename Type,
typename =
void>
684template<
typename,
typename =
void>
685struct has_iterator_category: std::false_type {};
687template<
typename Type>
688struct has_iterator_category<Type, std::void_t<typename std::iterator_traits<Type>::iterator_category>>: std::true_type {};
694template<
typename Type>
695struct is_iterator<Type, std::enable_if_t<!std::is_void_v<std::remove_cv_t<std::remove_pointer_t<Type>>>>>
696 : internal::has_iterator_category<Type> {};
702template<
typename Type>
710template<
typename Type>
712 : std::bool_constant<std::is_empty_v<Type> && !std::is_final_v<Type>> {};
718template<
typename Type>
726template<
typename Type,
typename =
void>
730template<
typename Type>
731struct is_transparent<Type, std::void_t<typename Type::is_transparent>>: std::true_type {};
737template<
typename Type>
743template<
typename,
typename =
void>
744struct has_tuple_size_value: std::false_type {};
746template<
typename Type>
747struct has_tuple_size_value<Type, std::void_t<decltype(std::tuple_size<const Type>::value)>>: std::true_type {};
749template<
typename,
typename =
void>
750struct has_value_type: std::false_type {};
752template<
typename Type>
753struct has_value_type<Type, std::void_t<typename Type::value_type>>: std::true_type {};
756[[nodiscard]]
constexpr bool dispatch_is_equality_comparable();
758template<
typename Type, std::size_t... Index>
759[[nodiscard]]
constexpr bool unpack_maybe_equality_comparable(std::index_sequence<Index...>) {
760 return (dispatch_is_equality_comparable<std::tuple_element_t<Index, Type>>() && ...);
764[[nodiscard]]
constexpr bool maybe_equality_comparable(
char) {
768template<
typename Type>
769[[nodiscard]]
constexpr auto maybe_equality_comparable(
int) ->
decltype(std::declval<Type>() == std::declval<Type>()) {
773template<
typename Type>
774[[nodiscard]]
constexpr bool dispatch_is_equality_comparable() {
775 if constexpr(std::is_array_v<Type>) {
777 }
else if constexpr(is_iterator_v<Type>) {
778 return maybe_equality_comparable<Type>(0);
779 }
else if constexpr(has_value_type<Type>::value) {
780 if constexpr(std::is_same_v<typename Type::value_type, Type>) {
781 return maybe_equality_comparable<Type>(0);
782 }
else if constexpr(dispatch_is_equality_comparable<typename Type::value_type>()) {
783 return maybe_equality_comparable<Type>(0);
787 }
else if constexpr(is_complete_v<std::tuple_size<std::remove_cv_t<Type>>>) {
788 if constexpr(has_tuple_size_value<Type>::value) {
789 return maybe_equality_comparable<Type>(0) && unpack_maybe_equality_comparable<Type>(std::make_index_sequence<std::tuple_size<Type>::value>{});
791 return maybe_equality_comparable<Type>(0);
794 return maybe_equality_comparable<Type>(0);
806template<
typename Type>
810template<
typename Type>
817template<
typename Type>
825template<
typename To,
typename From>
828 using type = std::remove_const_t<To>;
832template<
typename To,
typename From>
843template<
typename To,
typename From>
850template<
typename Member>
852 static_assert(std::is_member_pointer_v<Member>,
"Invalid pointer type to non-static member object or function");
854 template<
typename Class,
typename Ret,
typename... Args>
855 static Class *clazz(Ret (Class::*)(Args...));
857 template<
typename Class,
typename Ret,
typename... Args>
858 static Class *clazz(Ret (Class::*)(Args...)
const);
860 template<
typename Class,
typename Type>
861 static Class *clazz(Type Class::*);
865 using type = std::remove_pointer_t<decltype(clazz(std::declval<Member>()))>;
872template<
typename Member>
880template<std::
size_t Index,
typename Cand
idate>
882 template<
typename Ret,
typename... Args>
883 static constexpr type_list<Args...> pick_up(Ret (*)(Args...));
885 template<
typename Ret,
typename Class,
typename... Args>
886 static constexpr type_list<Args...> pick_up(Ret (Class ::*)(Args...));
888 template<
typename Ret,
typename Class,
typename... Args>
889 static constexpr type_list<Args...> pick_up(Ret (Class ::*)(Args...)
const);
891 template<
typename Type,
typename Class>
904template<std::
size_t Index,
typename Cand
idate>
909template<
typename... Type>
910struct std::tuple_size<
entt::type_list<Type...>>: std::integral_constant<std::size_t, entt::type_list<Type...>::size> {};
912template<std::size_t Index,
typename... Type>
915template<
auto... Value>
916struct std::tuple_size<
entt::value_list<Value...>>: std::integral_constant<std::size_t, entt::value_list<Value...>::size> {};
918template<std::size_t Index,
auto... Value>
Extracts the class of a non-static member object or function.
std::remove_pointer_t< decltype(clazz(std::declval< Member >()))> type
The class of the given non-static member object or function.
Extracts the n-th argument of a given function or member function.
type_list_element_t< Index, decltype(pick_up(std::declval< Candidate >()))> type
N-th argument of the given function or member function.
value_list_cat_t< std::conditional_t< value_list_contains_v< v141_toolset_workaround, Value >, value_list<>, value_list< Value > >... > type
A value list that is the difference between the two value lists.
Primary template isn't defined on purpose.
constexpr bool is_equality_comparable_v
Helper variable template.
constexpr choice_t< N > choice
Variable template for the choice trick.
typename type_identity< Type >::type type_identity_t
Helper type.
std::integral_constant< decltype(Value), Value > integral_constant
Wraps a static constant.
typename value_list_cat< List... >::type value_list_cat_t
Helper type.
constexpr std::size_t size_of_v
Helper variable template.
typename value_list_element< Index, List >::type value_list_element_t
Helper type.
constexpr std::size_t type_list_index_v
Helper variable template.
constexpr bool is_iterator_v
Helper variable template.
typename member_class< Member >::type member_class_t
Helper type.
constexpr auto value_list_element_v
Helper type.
typename type_list_transform< List, Op >::type type_list_transform_t
Helper type.
constexpr bool is_applicable_v
Helper variable template.
typename type_list_cat< List... >::type type_list_cat_t
Helper type.
constexpr bool is_transparent_v
Helper variable template.
typename type_list_unique< List >::type type_list_unique_t
Helper type.
typename constness_as< To, From >::type constness_as_t
Alias template to facilitate the transcription of the constness.
constexpr bool is_complete_v
Helper variable template.
constexpr bool type_list_contains_v
Helper variable template.
constexpr std::size_t value_list_index_v
Helper variable template.
typename value_list_diff< List... >::type value_list_diff_t
Helper type.
integral_constant< Value > tag
Alias template to facilitate the creation of named values.
constexpr type_list< Type..., Other... > operator+(type_list< Type... >, type_list< Other... >)
Concatenates multiple type lists.
constexpr bool value_list_contains_v
Helper variable template.
typename type_list_element< Index, List >::type type_list_element_t
Helper type.
typename value_list_unique< Type >::type value_list_unique_t
Helper type.
typename nth_argument< Index, Candidate >::type nth_argument_t
Helper type.
Type unpack_as_type
Using declaration to be used to repeat the same type a number of times equal to the size of a given p...
constexpr bool is_applicable_r_v
Helper variable template.
constexpr auto unpack_as_value
Helper variable template to be used to repeat the same value a number of times equal to the size of a...
typename type_list_diff< List... >::type type_list_diff_t
Helper type.
constexpr bool is_ebco_eligible_v
Helper variable template.
Utility class to disambiguate overloaded functions.
const To type
The type resulting from the transcription of the constness.
Transcribes the constness of a type to another type.
std::remove_const_t< To > type
The type resulting from the transcription of the constness.
Same as std::is_invocable_r, but with tuples for arguments.
Same as std::is_invocable, but with tuples.
Provides the member constant value to true if a given type is complete, false otherwise.
Provides the member constant value to true if a given type is both an empty and non-final class,...
Provides the member constant value to true if a given type is equality comparable,...
Provides the member constant value to true if a given type is an iterator, false otherwise.
Provides the member constant value to true if Type::is_transparent is valid and denotes a type,...
A type-only sizeof wrapper that returns 0 where sizeof complains.
typename type_list_cat< type_list< Type..., Other... >, List... >::type type
A type list composed by the types of all the type lists.
Concatenates multiple type lists.
Primary template isn't defined on purpose.
Provides the member constant value to true if a type list contains a given type, false otherwise.
type_list_cat_t< std::conditional_t< type_list_contains_v< type_list< Other... >, Type >, type_list<>, type_list< Type > >... > type
A type list that is the difference between the two type lists.
Primary template isn't defined on purpose.
Primary template isn't defined on purpose.
std::size_t value_type
Unsigned integer type.
std::size_t value_type
Unsigned integer type.
std::size_t value_type
Unsigned integer type.
Primary template isn't defined on purpose.
Removes duplicates types from a type list.
typename internal::type_list_unique< List >::type type
A type list without duplicate types.
A class to use to push around lists of types, nothing more.
static constexpr auto size
Compile-time number of elements in the type list.
typename value_list_cat< value_list< Value..., Other... >, List... >::type type
A value list composed by the values of all the value lists.
Concatenates multiple value lists.
Primary template isn't defined on purpose.
Provides the member constant value to true if a value list contains a given value,...
decltype(Value) type
Searched type.
Primary template isn't defined on purpose.
std::size_t value_type
Unsigned integer type.
std::size_t value_type
Unsigned integer type.
std::size_t value_type
Unsigned integer type.
Primary template isn't defined on purpose.
std::conditional_t<((Value==Other)||...), typename value_list_unique< value_list< Other... > >::type, value_list_cat_t< value_list< Value >, typename value_list_unique< value_list< Other... > >::type > > type
A value list without duplicate types.
Primary template isn't defined on purpose.
A class to use to push around lists of constant values, nothing more.
static constexpr auto size
Compile-time number of elements in the value list.