8 #define __PRETTY_FUNCTION__ __FUNCSIG__
22consteval uint32_t Hash32_CT(
const char * str,
size_t n, uint32_t
basis =
uint_least32_t( 2166136261 ) ) {
25consteval uint64_t Hash64_CT(
const char * str,
size_t n, uint64_t basis = uint_least64_t( 14695981039346656037U ) ) {
26 return n == 0 ? basis : Hash64_CT( str + 1, n - 1, ( basis ^ str[ 0 ] ) * uint_least64_t( 1099511628211 ) );
29consteval uint32_t Hash32_CT(
const char ( &s )[ N ] ) {
30 return Hash32_CT( s, N);
33consteval uint64_t Hash64_CT(
const char ( &s )[ N ] ) {
34 return Hash64_CT( s, N);
37consteval uint32_t Hash32_CT(
const std::string_view& v) {
38 return Hash32_CT(v.data(), v.size());
41consteval uint64_t Hash64_CT(
const std::string_view& v) {
42 return Hash64_CT(v.data(), v.size());
51consteval std::string_view type_name_impl<void>() {
57 using type_name_prober = void;
60 consteval std::string_view wrapped_type_name()
62 return __PRETTY_FUNCTION__;
65 consteval std::size_t wrapped_type_name_prefix_length() {
66 return wrapped_type_name<type_name_prober>().find(type_name_impl<type_name_prober>());
69 consteval std::size_t wrapped_type_name_suffix_length() {
70 return wrapped_type_name<type_name_prober>().length()
71 - wrapped_type_name_prefix_length()
72 - type_name_impl<type_name_prober>().length();
81 constexpr auto wrapped_name = detail::wrapped_type_name<T>();
82 constexpr auto prefix_length = detail::wrapped_type_name_prefix_length();
83 constexpr auto suffix_length = detail::wrapped_type_name_suffix_length();
92static constexpr bool fundamental_specialized = std::is_fundamental<T>::value && !std::is_same<T,void>::value;
94template<
typename T, std::enable_if_t<fundamental_specialized<T>,
bool> = false>
95consteval std::string_view type_name() {
96 return type_name_impl<T>();
100static constexpr bool is_eligible = (std::is_base_of<RavEngine::AutoCTTI, T>::value || std::is_trivially_copyable<T>::value) && (!std::is_same<T,void>::value && !fundamental_specialized<T>);
103static constexpr bool is_ineligible = !is_eligible<T> && !fundamental_specialized<T>;
106template <
typename T, std::enable_if_t<is_eligible<T>,
bool> = false>
107consteval std::string_view type_name() {
109 constexpr auto str = type_name_impl<T>();
111 static_assert(str[0] ==
'c' || str[0] ==
's',
"Type must be a class or struct");
112 if constexpr (str[0] ==
'c'){
113 offset =
sizeof(
"class");
115 else if (str[0] ==
's'){
116 offset =
sizeof(
"struct");
118 return std::string_view(str.data() + offset, str.size() - offset);
120 return type_name_impl<T>();
126template<
typename T, std::enable_if_t<is_ineligible<T>,
bool> = false>
127consteval std::string_view type_name(){
128 static_assert(is_ineligible<T>,
"A platform-independent type-name string cannot be auto-generated for this type. Create a manual specialization. See mathtypes.hpp for an example.");
138static consteval ctti_t CTTI(){
139 return Hash32_CT(type_name<T>());
Definition concurrentqueue.h:747
uint64 uint64_t
Definition fwd.hpp:145
uint32 uint32_t
Definition fwd.hpp:131
Definition Animation.hpp:6
consteval std::string_view type_name_impl()
Definition CTTI.hpp:80