4#ifndef GREM_CORE_METAPROGRAMMING_HPP
5#define GREM_CORE_METAPROGRAMMING_HPP
19#include <source_location>
25struct GREM_private_MetaReflectionStruct {
26 char GREM_private_metaReflectionField;
28enum class GREM_private_MetaReflectionEnum {
29 GREM_PRIVATE_META_REFLECTION_ENUMERAND,
60template <
typename... Ts>
78template <
size_t N,
typename T,
typename... Args>
79[[nodiscard]]
constexpr auto createN(Args&&... args) {
80 return [&]<std::size_t... Indices>(std::index_sequence<Indices...>) {
81 const auto createElement = [&]() -> T {
84 return Array<T, N>{{((void)Indices, createElement())...}};
85 }(std::make_index_sequence<N>{});
98template <
typename T,
size_t N>
100 return [&array, fn]<std::size_t... Indices>(std::index_sequence<Indices...>) {
101 return Array{fn(array[Indices])...};
102 }(std::make_index_sequence<N>{});
115template <
typename T,
size_t N>
117 return [&array, fn]<std::size_t... Indices>(std::index_sequence<Indices...>) {
118 return Array{fn(array[Indices])...};
119 }(std::make_index_sequence<N>{});
132template <
typename T,
size_t N>
134 return [&array, fn]<std::size_t... Indices>(std::index_sequence<Indices...>) {
135 return Array{fn(std::move(array[Indices]))...};
136 }(std::make_index_sequence<N>{});
149template <
typename T,
size_t N>
151 return [&array, fn]<std::size_t... Indices>(std::index_sequence<Indices...>) {
152 return Array{fn(std::move(array[Indices]))...};
153 }(std::make_index_sequence<N>{});
166[[nodiscard]]
constexpr auto transform(
auto&& tuple,
auto fn) {
167 return [&tuple, fn]<std::size_t... Indices>(std::index_sequence<Indices...>) {
169 }(std::make_index_sequence<tuple_size_v<std::remove_cvref_t<
decltype(tuple)>>>{});
181constexpr void forEach(
auto&& tuple,
auto fn) {
182 [&tuple, fn]<std::size_t... Indices>(std::index_sequence<Indices...>) {
184 }(std::make_index_sequence<tuple_size_v<std::remove_cvref_t<
decltype(tuple)>>>{});
194 static constexpr const auto&
value = X;
228template <std::
size_t N>
230 [fn]<std::size_t... Indices>(std::index_sequence<Indices...>) ->
void {
232 }(std::make_index_sequence<N>{});
249template <
size_t N,
typename T>
251 if constexpr (N == 0) {
254 return [fn]<std::size_t... Indices>(std::index_sequence<Indices...>) {
255 if constexpr (
requires {
262 }(std::make_index_sequence<N>{});
282template <std::
size_t N>
283constexpr decltype(
auto)
visitIndex(std::size_t index,
auto fn) {
284 return [index, fn]<std::size_t... Indices>(std::index_sequence<Indices...>) ->
decltype(
auto) {
286 if constexpr (std::is_void_v<R>) {
288 throw std::out_of_range{
"index >= N"};
290 }
else if constexpr (std::is_lvalue_reference_v<R>) {
291 std::remove_reference_t<R>* result =
nullptr;
292 if (!(((index == Indices) ? ((result = &fn(
CONSTANT<Indices>)),
true) :
false) || ...)) {
293 throw std::out_of_range{
"index >= N"};
302 constexpr ~MaybeValue() {}
306 bool hasValue =
false;
308 constexpr ~Result() {
310 std::destroy_at(&value.actual);
314 if (!(((index == Indices) ? (std::construct_at(&result.value.actual, fn(
CONSTANT<Indices>)),
true) :
false) || ...)) {
315 throw std::out_of_range{
"index >= N"};
317 result.hasValue =
true;
318 return R{std::move(result.value.actual)};
320 }(std::make_index_sequence<N>{});
346template <
typename... Ts>
356template <
typename... Ts>
361struct is_type_list : std::false_type {};
363template <
typename... Ts>
364struct is_type_list<TypeList<Ts...>> : std::true_type {};
385template <
typename List>
386struct type_list_size;
388template <
typename... Ts>
389struct type_list_size<
TypeList<Ts...>> : std::integral_constant<std::size_t, sizeof...(Ts)> {};
398template <
typename List>
402template <
typename List>
403struct type_list_empty;
405template <
typename... Ts>
406struct type_list_empty<
TypeList<Ts...>> : std::false_type {};
409struct type_list_empty<TypeList<>> : std::true_type {};
417template <
typename List>
422template <std::size_t Index,
typename This,
typename... Rest>
423struct TypeListTypeImpl : TypeListTypeImpl<Index - 1, Rest...> {};
425template <
typename This,
typename... Rest>
426struct TypeListTypeImpl<0, This, Rest...> {
433template <
typename List, std::
size_t Index>
434struct type_list_type;
436template <
typename... Ts, std::size_t Index>
437struct type_list_type<TypeList<Ts...>, Index> : detail::TypeListTypeImpl<Index, Ts...> {};
447template <
typename List, std::
size_t Index>
452template <
typename T,
typename This,
typename... Rest>
453struct TypeListContainsImpl : std::conditional_t<std::is_same_v<T, This>, std::true_type, TypeListContainsImpl<T, Rest...>> {};
455template <
typename T,
typename This>
456struct TypeListContainsImpl<T, This> : std::bool_constant<std::is_same_v<T, This>> {};
461template <
typename List,
typename T>
462struct type_list_contains;
464template <
typename... Ts,
typename T>
465struct type_list_contains<TypeList<Ts...>, T> : detail::TypeListContainsImpl<T, Ts...> {};
474template <
typename List,
typename T>
479template <std::size_t Index,
typename T,
typename... Ts>
480[[nodiscard]]
consteval std::size_t getTypeListIndex()
noexcept {
484 }
else if constexpr (Index + 1 <
sizeof...(Ts)) {
485 return getTypeListIndex<Index + 1, T, Ts...>();
492template <
typename List,
typename T>
493struct type_list_index;
495template <
typename... Ts,
typename T>
496struct type_list_index<TypeList<Ts...>, T> : std::integral_constant<std::size_t, detail::getTypeListIndex<0, T, Ts...>()> {};
508template <
typename List,
typename T>
513template <std::size_t Index,
typename T,
typename... Ts>
514[[nodiscard]]
consteval std::size_t getTypeListReverseIndex()
noexcept {
518 }
else if constexpr (Index > 0) {
519 return getTypeListReverseIndex<Index - 1, T, Ts...>();
526template <
typename List,
typename T>
527struct type_list_rindex;
529template <
typename... Ts,
typename T>
530struct type_list_rindex<TypeList<Ts...>, T> : std::integral_constant<std::size_t, detail::getTypeListReverseIndex<sizeof...(Ts) - 1, T, Ts...>()> {};
542template <
typename List,
typename T>
547template <std::size_t Index,
typename T,
typename... Ts>
548[[nodiscard]]
consteval std::size_t getTypeListCount()
noexcept {
549 if constexpr (Index >=
sizeof...(Ts)) {
552 return 1 + getTypeListCount<Index + 1, T, Ts...>();
554 return getTypeListCount<Index + 1, T, Ts...>();
561template <
typename List,
typename T>
562struct type_list_count;
564template <
typename... Ts,
typename T>
565struct type_list_count<TypeList<Ts...>, T> : std::integral_constant<std::size_t, detail::getTypeListCount<0, T, Ts...>()> {};
575template <
typename List,
typename T>
579template <
typename... Lists>
580struct type_list_concat;
583struct type_list_concat<> {
587template <
typename... Ts>
588struct type_list_concat<TypeList<Ts...>> {
589 using type = TypeList<Ts...>;
592template <
typename... Ts,
typename... Us,
typename... Rest>
593struct type_list_concat<TypeList<Ts...>, TypeList<Us...>, Rest...> : type_list_concat<TypeList<Ts..., Us...>, Rest...> {};
603template <
typename... Lists>
607template <
typename List,
typename PrefixList>
608struct type_list_starts_with;
610template <
typename... Ts,
typename... Us>
611struct type_list_starts_with<
TypeList<Ts...>,
TypeList<Us...>> : std::false_type {};
613template <
typename... Ts>
614struct type_list_starts_with<TypeList<Ts...>, TypeList<>> : std::true_type {};
616template <
typename First,
typename... Rest,
typename... RestPrefix>
617struct type_list_starts_with<TypeList<First, Rest...>, TypeList<First, RestPrefix...>> : type_list_starts_with<TypeList<Rest...>, TypeList<RestPrefix...>> {};
628template <
typename List,
typename PrefixList>
640template <
typename List,
typename T>
641struct type_list_starts_with_type;
643template <
typename... Ts,
typename U>
644struct type_list_starts_with_type<
TypeList<Ts...>, U> : std::false_type {};
646template <
typename T,
typename... Rest>
647struct type_list_starts_with_type<TypeList<T, Rest...>, T> : std::true_type {};
656template <
typename List,
typename T>
672template <
typename List>
674 [fn]<
typename... Ts>(
TypeList<Ts...>) ->
void {
683#pragma clang diagnostic push
684#pragma clang diagnostic ignored "-Wundefined-inline"
686 template <
typename T>
687 constexpr operator T() const noexcept;
689#pragma clang diagnostic pop
693template <std::
size_t Index>
694struct AggregateSizeTag : AggregateSizeTag<Index - 1> {};
697struct AggregateSizeTag<0> {};
700template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<32>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 32; }
701template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<31>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 31; }
702template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<30>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 30; }
703template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<29>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 29; }
704template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<28>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 28; }
705template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<27>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 27; }
706template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<26>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 26; }
707template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<25>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 25; }
708template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<24>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 24; }
709template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<23>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 23; }
710template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<22>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 22; }
711template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<21>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 21; }
712template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<20>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 20; }
713template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<19>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 19; }
714template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<18>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 18; }
715template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<17>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 17; }
716template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<16>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 16; }
717template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<15>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 15; }
718template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<14>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 14; }
719template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<13>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 13; }
720template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<12>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 12; }
721template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<11>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 11; }
722template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag<10>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 10; }
723template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag< 9>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 9; }
724template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag< 8>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 8; }
725template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag< 7>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 7; }
726template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag< 6>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 6; }
727template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag< 5>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 5; }
728template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag< 4>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}, Init{}}, std::size_t{}) {
return 4; }
729template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag< 3>)
noexcept ->
decltype(Aggregate{Init{}, Init{}, Init{}}, std::size_t{}) {
return 3; }
730template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag< 2>)
noexcept ->
decltype(Aggregate{Init{}, Init{}}, std::size_t{}) {
return 2; }
731template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag< 1>)
noexcept ->
decltype(Aggregate{Init{}}, std::size_t{}) {
return 1; }
732template <
typename Aggregate> [[nodiscard]]
consteval auto getAggregateSize(AggregateSizeTag< 0>)
noexcept ->
decltype(Aggregate{}, std::size_t{}) {
return 0; }
736[[nodiscard]]
consteval StringView getTypeDependentFunctionName() noexcept {
737 return std::source_location::current().function_name();
741[[nodiscard]]
consteval StringView getValueDependentFunctionName() noexcept {
742 return std::source_location::current().function_name();
756#pragma clang diagnostic push
757#pragma clang diagnostic ignored "-Wundefined-internal"
760GREM_EXPORT extern const DummyWrapper<T> DUMMY_VALUE_WRAPPER;
762#pragma clang diagnostic pop
766[[nodiscard]]
consteval const T& getDummyValue() noexcept {
768#pragma clang diagnostic push
769#pragma clang diagnostic ignored "-Wundefined-var-template"
771 return DUMMY_VALUE_WRAPPER<T>.value;
773#pragma clang diagnostic pop
777struct PrimitiveTypeNameExtraction {
779 static constexpr StringView TEST_TYPE_NAME =
"char";
780 static constexpr StringView TEST_DEPENDENT_FUNCTION_NAME = getTypeDependentFunctionName<char>();
783 static constexpr size_t OFFSET = TEST_DEPENDENT_FUNCTION_NAME.find(TEST_TYPE_NAME);
784 static constexpr StringView SUFFIX = TEST_DEPENDENT_FUNCTION_NAME.substr(OFFSET + TEST_TYPE_NAME.size());
787struct ClassTypeNameExtraction {
789 static constexpr StringView TEST_TYPE_NAME =
"GREM_private_MetaReflectionStruct";
790 static constexpr StringView TEST_DEPENDENT_FUNCTION_NAME = getTypeDependentFunctionName<GREM_private_MetaReflectionStruct>();
793 static constexpr size_t OFFSET = [] {
794 const size_t i = TEST_DEPENDENT_FUNCTION_NAME.find(TEST_TYPE_NAME);
795 if (i > 6 && TEST_DEPENDENT_FUNCTION_NAME.substr(i - 6).starts_with(
"class ")) {
798 if (i > 7 && TEST_DEPENDENT_FUNCTION_NAME.substr(i - 7).starts_with(
"struct ")) {
803 static constexpr StringView SUFFIX = TEST_DEPENDENT_FUNCTION_NAME.substr(TEST_DEPENDENT_FUNCTION_NAME.find(TEST_TYPE_NAME) + TEST_TYPE_NAME.size());
806struct EnumTypeNameExtraction {
808 static constexpr StringView TEST_TYPE_NAME =
"GREM_private_MetaReflectionEnum";
809 static constexpr StringView TEST_DEPENDENT_FUNCTION_NAME = getTypeDependentFunctionName<GREM_private_MetaReflectionEnum>();
812 static constexpr size_t OFFSET = [] {
813 const size_t i = TEST_DEPENDENT_FUNCTION_NAME.find(TEST_TYPE_NAME);
814 if (i > 5 && TEST_DEPENDENT_FUNCTION_NAME.substr(i - 5).starts_with(
"enum ")) {
819 static constexpr StringView SUFFIX = TEST_DEPENDENT_FUNCTION_NAME.substr(TEST_DEPENDENT_FUNCTION_NAME.find(TEST_TYPE_NAME) + TEST_TYPE_NAME.size());
823struct TypeNameExtraction : PrimitiveTypeNameExtraction {};
825template <
typename Class>
826requires std::is_class_v<Class>
struct TypeNameExtraction<Class> : ClassTypeNameExtraction {};
828template <enumeration Enum>
829struct TypeNameExtraction<Enum> : EnumTypeNameExtraction {};
831struct AggregateFieldNameExtraction {
833 static constexpr StringView TEST_FIELD_NAME =
"GREM_private_metaReflectionField";
834 static constexpr StringView TEST_DEPENDENT_FUNCTION_NAME =
835 getValueDependentFunctionName<Reference{getDummyValue<GREM_private_MetaReflectionStruct>().GREM_private_metaReflectionField}>();
836 static constexpr size_t TEST_OFFSET = TEST_DEPENDENT_FUNCTION_NAME.find(TEST_FIELD_NAME);
839 static constexpr char PREFIX = TEST_DEPENDENT_FUNCTION_NAME[TEST_OFFSET - 1];
840 static constexpr StringView SUFFIX = TEST_DEPENDENT_FUNCTION_NAME.substr(TEST_OFFSET + TEST_FIELD_NAME.size());
843struct EnumerandNameExtraction {
845 static constexpr StringView TEST_ENUMERAND_NAME =
"GREM_private_MetaReflectionEnum::GREM_PRIVATE_META_REFLECTION_ENUMERAND";
846 static constexpr StringView TEST_DEPENDENT_FUNCTION_NAME = getValueDependentFunctionName<GREM_private_MetaReflectionEnum::GREM_PRIVATE_META_REFLECTION_ENUMERAND>();
849 static constexpr size_t OFFSET = TEST_DEPENDENT_FUNCTION_NAME.find(TEST_ENUMERAND_NAME);
850 static constexpr size_t SUFFIX_LENGTH = TEST_DEPENDENT_FUNCTION_NAME.size() - OFFSET - TEST_ENUMERAND_NAME.size();
853template <
typename R,
typename... Args>
854[[nodiscard]]
consteval TypeList<Args...> getFunctionParameterTypes(R (*)(Args...));
856template <
typename R,
typename... Args>
857[[nodiscard]]
consteval TypeList<Args...> getFunctionParameterTypes(R (*)(Args...)
noexcept);
859template <
typename R,
typename U,
typename... Args>
860[[nodiscard]]
consteval TypeList<Args...> getFunctionParameterTypes(R (U::*)(Args...));
862template <
typename R,
typename U,
typename... Args>
863[[nodiscard]]
consteval TypeList<Args...> getFunctionParameterTypes(R (U::*)(Args...)
noexcept);
865template <
typename R,
typename U,
typename... Args>
866[[nodiscard]]
consteval TypeList<Args...> getFunctionParameterTypes(R (U::*)(Args...)
const);
868template <
typename R,
typename U,
typename... Args>
869[[nodiscard]]
consteval TypeList<Args...> getFunctionParameterTypes(R (U::*)(Args...)
const noexcept);
871template <
typename Function>
872[[nodiscard]]
consteval auto getFunctionParameterTypes(
Function) ->
decltype(getFunctionParameterTypes(&Function::operator()));
874template <
typename R,
typename... Args>
875[[nodiscard]]
consteval R getFunctionReturnType(R (*)(Args...));
877template <
typename R,
typename... Args>
878[[nodiscard]]
consteval R getFunctionReturnType(R (*)(Args...)
noexcept);
880template <
typename R,
typename U,
typename... Args>
881[[nodiscard]]
consteval R getFunctionReturnType(R (U::*)(Args...));
883template <
typename R,
typename U,
typename... Args>
884[[nodiscard]]
consteval R getFunctionReturnType(R (U::*)(Args...)
noexcept);
886template <
typename R,
typename U,
typename... Args>
887[[nodiscard]]
consteval R getFunctionReturnType(R (U::*)(Args...)
const);
889template <
typename R,
typename U,
typename... Args>
890[[nodiscard]]
consteval R getFunctionReturnType(R (U::*)(Args...)
const noexcept);
892template <
typename Function>
893[[nodiscard]]
consteval auto getFunctionReturnType(
Function) ->
decltype(getFunctionReturnType(&Function::operator()));
895template <
typename... Ts>
896[[nodiscard]]
consteval auto getVariantAlternativeTypes(
const Variant<Ts...>&) -> TypeList<Ts...>;
898template <
typename... Ts>
899[[nodiscard]]
consteval auto getTupleElementTypes(
const Tuple<Ts...>&) -> TypeList<Ts...>;
901template <
typename... Ts>
902[[nodiscard]]
consteval Tuple<Ts...> getTupleOfVariantAlternatives(
const Variant<Ts...>&);
907template <aggregate Aggregate>
908struct aggregate_size : std::integral_constant<std::size_t, detail::getAggregateSize<Aggregate>(detail::AggregateSizeTag<32>{})> {};
920template <
typename Aggregate>
938template <
typename Aggregate>
946[[nodiscard]]
consteval auto getAggregateFieldTypes(
auto&& value)
noexcept {
947 using Aggregate = std::remove_cvref_t<
decltype(value)>;
950 if constexpr (FIELD_COUNT == 32) {
951 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac, ad, ae, af] = value;
952 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
953 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u),
decltype(v),
decltype(w),
decltype(x),
decltype(y),
954 decltype(z),
decltype(aa),
decltype(ab),
decltype(ac),
decltype(ad),
decltype(ae),
decltype(af)>;
955 }
else if constexpr (FIELD_COUNT == 31) {
956 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac, ad, ae] = value;
957 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
958 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u),
decltype(v),
decltype(w),
decltype(x),
decltype(y),
959 decltype(z),
decltype(aa),
decltype(ab),
decltype(ac),
decltype(ad),
decltype(ae)>;
960 }
else if constexpr (FIELD_COUNT == 30) {
961 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac, ad] = value;
962 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
963 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u),
decltype(v),
decltype(w),
decltype(x),
decltype(y),
964 decltype(z),
decltype(aa),
decltype(ab),
decltype(ac),
decltype(ad)>;
965 }
else if constexpr (FIELD_COUNT == 29) {
966 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac] = value;
967 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
968 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u),
decltype(v),
decltype(w),
decltype(x),
decltype(y),
969 decltype(z),
decltype(aa),
decltype(ab),
decltype(ac)>;
970 }
else if constexpr (FIELD_COUNT == 28) {
971 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab] = value;
972 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
973 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u),
decltype(v),
decltype(w),
decltype(x),
decltype(y),
974 decltype(z),
decltype(aa),
decltype(ab)>;
975 }
else if constexpr (FIELD_COUNT == 27) {
976 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa] = value;
977 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
978 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u),
decltype(v),
decltype(w),
decltype(x),
decltype(y),
979 decltype(z),
decltype(aa)>;
980 }
else if constexpr (FIELD_COUNT == 26) {
981 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z] = value;
982 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
983 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u),
decltype(v),
decltype(w),
decltype(x),
decltype(y),
985 }
else if constexpr (FIELD_COUNT == 25) {
986 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y] = value;
987 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
988 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u),
decltype(v),
decltype(w),
decltype(x),
990 }
else if constexpr (FIELD_COUNT == 24) {
991 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x] = value;
992 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
993 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u),
decltype(v),
decltype(w),
decltype(x)>;
994 }
else if constexpr (FIELD_COUNT == 23) {
995 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w] = value;
996 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
997 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u),
decltype(v),
decltype(w)>;
998 }
else if constexpr (FIELD_COUNT == 22) {
999 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v] = value;
1000 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
1001 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u),
decltype(v)>;
1002 }
else if constexpr (FIELD_COUNT == 21) {
1003 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u] = value;
1004 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
1005 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t),
decltype(u)>;
1006 }
else if constexpr (FIELD_COUNT == 20) {
1007 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t] = value;
1008 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
1009 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s),
decltype(t)>;
1010 }
else if constexpr (FIELD_COUNT == 19) {
1011 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s] = value;
1012 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
1013 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r),
decltype(s)>;
1014 }
else if constexpr (FIELD_COUNT == 18) {
1015 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = value;
1016 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
1017 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q),
decltype(r)>;
1018 }
else if constexpr (FIELD_COUNT == 17) {
1019 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q] = value;
1020 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
1021 decltype(m),
decltype(n),
decltype(o),
decltype(p),
decltype(q)>;
1022 }
else if constexpr (FIELD_COUNT == 16) {
1023 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p] = value;
1024 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
1025 decltype(m),
decltype(n),
decltype(o),
decltype(p)>;
1026 }
else if constexpr (FIELD_COUNT == 15) {
1027 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o] = value;
1028 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
1029 decltype(m),
decltype(n),
decltype(o)>;
1030 }
else if constexpr (FIELD_COUNT == 14) {
1031 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n] = value;
1032 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
1033 decltype(m),
decltype(n)>;
1034 }
else if constexpr (FIELD_COUNT == 13) {
1035 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m] = value;
1036 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
decltype(l),
1038 }
else if constexpr (FIELD_COUNT == 12) {
1039 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k, l] = value;
1040 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k),
1042 }
else if constexpr (FIELD_COUNT == 11) {
1043 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j, k] = value;
1044 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j),
decltype(k)>;
1045 }
else if constexpr (FIELD_COUNT == 10) {
1046 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i, j] = value;
1047 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i),
decltype(j)>;
1048 }
else if constexpr (FIELD_COUNT == 9) {
1049 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h, i] = value;
1050 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h),
decltype(i)>;
1051 }
else if constexpr (FIELD_COUNT == 8) {
1052 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g, h] = value;
1053 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g),
decltype(h)>;
1054 }
else if constexpr (FIELD_COUNT == 7) {
1055 [[maybe_unused]]
auto&& [a, b, c, d, e, f, g] = value;
1056 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f),
decltype(g)>;
1057 }
else if constexpr (FIELD_COUNT == 6) {
1058 [[maybe_unused]]
auto&& [a, b, c, d, e, f] = value;
1059 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e),
decltype(f)>;
1060 }
else if constexpr (FIELD_COUNT == 5) {
1061 [[maybe_unused]]
auto&& [a, b, c, d, e] = value;
1062 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d),
decltype(e)>;
1063 }
else if constexpr (FIELD_COUNT == 4) {
1064 [[maybe_unused]]
auto&& [a, b, c, d] = value;
1065 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c),
decltype(d)>;
1066 }
else if constexpr (FIELD_COUNT == 3) {
1067 [[maybe_unused]]
auto&& [a, b, c] = value;
1068 return TYPE_LIST<
decltype(a),
decltype(b),
decltype(c)>;
1069 }
else if constexpr (FIELD_COUNT == 2) {
1070 [[maybe_unused]]
auto&& [a, b] = value;
1071 return TYPE_LIST<
decltype(a),
decltype(b)>;
1072 }
else if constexpr (FIELD_COUNT == 1) {
1073 [[maybe_unused]]
auto&& [a] = value;
1083template <aggregate Aggregate>
1084struct aggregate_field_types {
1085 using type =
decltype(detail::getAggregateFieldTypes(std::declval<Aggregate>()));
1098template <
typename Aggregate>
1102template <std::
size_t Index, aggregate Aggregate>
1103struct aggregate_field_type {
1118template <std::
size_t Index,
typename Aggregate>
1135template <
typename Aggregate>
1159template <
typename Aggregate>
1178[[nodiscard]]
constexpr auto getFields(
auto&& value)
noexcept {
1179 using Aggregate = std::remove_cvref_t<
decltype(value)>;
1182 if constexpr (FIELD_COUNT == 32) {
1183 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac, ad, ae, af] = value;
1184 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac, ad, ae, af);
1185 }
else if constexpr (FIELD_COUNT == 31) {
1186 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac, ad, ae] = value;
1187 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac, ad, ae);
1188 }
else if constexpr (FIELD_COUNT == 30) {
1189 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac, ad] = value;
1190 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac, ad);
1191 }
else if constexpr (FIELD_COUNT == 29) {
1192 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac] = value;
1193 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab, ac);
1194 }
else if constexpr (FIELD_COUNT == 28) {
1195 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab] = value;
1196 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, ab);
1197 }
else if constexpr (FIELD_COUNT == 27) {
1198 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa] = value;
1199 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa);
1200 }
else if constexpr (FIELD_COUNT == 26) {
1201 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z] = value;
1202 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z);
1203 }
else if constexpr (FIELD_COUNT == 25) {
1204 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y] = value;
1205 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y);
1206 }
else if constexpr (FIELD_COUNT == 24) {
1207 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x] = value;
1208 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x);
1209 }
else if constexpr (FIELD_COUNT == 23) {
1210 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w] = value;
1211 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w);
1212 }
else if constexpr (FIELD_COUNT == 22) {
1213 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v] = value;
1214 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v);
1215 }
else if constexpr (FIELD_COUNT == 21) {
1216 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u] = value;
1217 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u);
1218 }
else if constexpr (FIELD_COUNT == 20) {
1219 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t] = value;
1220 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t);
1221 }
else if constexpr (FIELD_COUNT == 19) {
1222 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s] = value;
1223 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s);
1224 }
else if constexpr (FIELD_COUNT == 18) {
1225 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = value;
1226 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r);
1227 }
else if constexpr (FIELD_COUNT == 17) {
1228 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q] = value;
1229 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q);
1230 }
else if constexpr (FIELD_COUNT == 16) {
1231 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p] = value;
1232 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p);
1233 }
else if constexpr (FIELD_COUNT == 15) {
1234 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o] = value;
1235 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
1236 }
else if constexpr (FIELD_COUNT == 14) {
1237 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n] = value;
1238 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
1239 }
else if constexpr (FIELD_COUNT == 13) {
1240 auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m] = value;
1241 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l, m);
1242 }
else if constexpr (FIELD_COUNT == 12) {
1243 auto&& [a, b, c, d, e, f, g, h, i, j, k, l] = value;
1244 return grem::tie(a, b, c, d, e, f, g, h, i, j, k, l);
1245 }
else if constexpr (FIELD_COUNT == 11) {
1246 auto&& [a, b, c, d, e, f, g, h, i, j, k] = value;
1247 return grem::tie(a, b, c, d, e, f, g, h, i, j, k);
1248 }
else if constexpr (FIELD_COUNT == 10) {
1249 auto&& [a, b, c, d, e, f, g, h, i, j] = value;
1250 return grem::tie(a, b, c, d, e, f, g, h, i, j);
1251 }
else if constexpr (FIELD_COUNT == 9) {
1252 auto&& [a, b, c, d, e, f, g, h, i] = value;
1253 return grem::tie(a, b, c, d, e, f, g, h, i);
1254 }
else if constexpr (FIELD_COUNT == 8) {
1255 auto&& [a, b, c, d, e, f, g, h] = value;
1256 return grem::tie(a, b, c, d, e, f, g, h);
1257 }
else if constexpr (FIELD_COUNT == 7) {
1258 auto&& [a, b, c, d, e, f, g] = value;
1260 }
else if constexpr (FIELD_COUNT == 6) {
1261 auto&& [a, b, c, d, e, f] = value;
1263 }
else if constexpr (FIELD_COUNT == 5) {
1264 auto&& [a, b, c, d, e] = value;
1266 }
else if constexpr (FIELD_COUNT == 4) {
1267 auto&& [a, b, c, d] = value;
1269 }
else if constexpr (FIELD_COUNT == 3) {
1270 auto&& [a, b, c] = value;
1272 }
else if constexpr (FIELD_COUNT == 2) {
1273 auto&& [a, b] = value;
1275 }
else if constexpr (FIELD_COUNT == 1) {
1296template <
typename Aggregate>
1317template <
typename Aggregate>
1319 auto&& fields =
getFields(std::forward<Aggregate>(value));
1328template <
typename T>
struct remove_qualifiers {
using type = T; };
1329template <
typename T>
struct remove_qualifiers<const T> : remove_qualifiers<T> {};
1330template <
typename T>
struct remove_qualifiers<volatile
T> : remove_qualifiers<T> {};
1331template <
typename T>
struct remove_qualifiers<const volatile
T> : remove_qualifiers<T> {};
1332template <
typename T>
struct remove_qualifiers<
T&> : remove_qualifiers<T> {};
1333template <
typename T>
struct remove_qualifiers<const
T&> : remove_qualifiers<T> {};
1334template <
typename T>
struct remove_qualifiers<volatile
T&> : remove_qualifiers<T> {};
1335template <
typename T>
struct remove_qualifiers<const volatile
T&> : remove_qualifiers<T> {};
1336template <
typename T>
struct remove_qualifiers<
T&&> : remove_qualifiers<T> {};
1337template <
typename T>
struct remove_qualifiers<const
T&&> : remove_qualifiers<T> {};
1338template <
typename T>
struct remove_qualifiers<volatile
T&&> : remove_qualifiers<T> {};
1339template <
typename T>
struct remove_qualifiers<const volatile
T&&> : remove_qualifiers<T> {};
1340template <
typename T>
struct remove_qualifiers<
T*> : remove_qualifiers<T> {};
1341template <
typename T>
struct remove_qualifiers<const
T*> : remove_qualifiers<T> {};
1342template <
typename T>
struct remove_qualifiers<volatile
T*> : remove_qualifiers<T> {};
1343template <
typename T>
struct remove_qualifiers<const volatile
T*> : remove_qualifiers<T> {};
1344template <
typename T>
struct remove_qualifiers<
T[]> : remove_qualifiers<T> {};
1345template <
typename T>
struct remove_qualifiers<const
T[]> : remove_qualifiers<T> {};
1346template <
typename T>
struct remove_qualifiers<volatile
T[]> : remove_qualifiers<T> {};
1347template <
typename T>
struct remove_qualifiers<const volatile
T[]> : remove_qualifiers<T> {};
1348template <
typename T,
size_t N>
struct remove_qualifiers<
T[
N]> : remove_qualifiers<T> {};
1349template <
typename T,
size_t N>
struct remove_qualifiers<const
T[
N]> : remove_qualifiers<T> {};
1350template <
typename T,
size_t N>
struct remove_qualifiers<volatile
T[
N]> : remove_qualifiers<T> {};
1351template <
typename T,
size_t N>
struct remove_qualifiers<const volatile
T[
N]> : remove_qualifiers<T> {};
1354template <
typename T>
1355using remove_qualifiers_t =
typename remove_qualifiers<T>::type;
1358 name.remove_prefix(offset);
1359 name = name.substr(0, name.rfind(suffix));
1361 while (name.starts_with(
' ')) {
1362 name.remove_prefix(1);
1364 if (name.starts_with(
"const")) {
1365 name.remove_prefix(5);
1366 }
else if (name.starts_with(
"volatile")) {
1367 name.remove_prefix(8);
1368 }
else if (name.starts_with(
"struct")) {
1369 name.remove_prefix(6);
1370 }
else if (name.starts_with(
"class")) {
1371 name.remove_prefix(5);
1372 }
else if (name.starts_with(
"enum")) {
1373 name.remove_prefix(4);
1378 name.remove_prefix(name.rfind(
':') + 1);
1379 name = name.substr(0, name.find_first_of(
" <[*&"));
1383template <
typename T>
1384[[nodiscard]]
constexpr StringView getUnqualifiedTypeName() noexcept {
1385 using X = remove_qualifiers_t<T>;
1386 if constexpr (std::is_same_v<X, signed char>) {
1387 return "signed char";
1388 }
else if constexpr (std::is_same_v<X, unsigned char>) {
1389 return "unsigned char";
1390 }
else if constexpr (std::is_same_v<X, short>) {
1392 }
else if constexpr (std::is_same_v<X, unsigned short>) {
1393 return "unsigned short";
1394 }
else if constexpr (std::is_same_v<X, int>) {
1396 }
else if constexpr (std::is_same_v<X, unsigned int>) {
1397 return "unsigned int";
1398 }
else if constexpr (std::is_same_v<X, long>) {
1400 }
else if constexpr (std::is_same_v<X, unsigned long>) {
1401 return "unsigned long";
1402 }
else if constexpr (std::is_same_v<X, long long>) {
1404 }
else if constexpr (std::is_same_v<X, unsigned long long>) {
1405 return "unsigned long long";
1406 }
else if constexpr (std::is_same_v<X, char>) {
1408 }
else if constexpr (std::is_same_v<X, wchar_t>) {
1410 }
else if constexpr (std::is_same_v<X, char8_t>) {
1412 }
else if constexpr (std::is_same_v<X, char16_t>) {
1414 }
else if constexpr (std::is_same_v<X, char32_t>) {
1416 }
else if constexpr (std::is_same_v<X, float>) {
1418 }
else if constexpr (std::is_same_v<X, double>) {
1420 }
else if constexpr (std::is_same_v<X, long double>) {
1421 return "long double";
1423 using Extraction = TypeNameExtraction<X>;
1424 constexpr StringView NAME = extractUnqualifiedTypeName(getTypeDependentFunctionName<X>(), Extraction::OFFSET, Extraction::SUFFIX);
1425 if (std::is_constant_evaluated()) {
1429 static constexpr ConstantString<char, NAME.size()> RESULT = NAME;
1436 name = name.substr(0, name.find(suffix));
1437 name.remove_prefix(name.rfind(prefix) + 1);
1441template <std::
size_t Index,
typename Aggregate>
1442[[nodiscard]]
constexpr StringView getAggregateFieldName() noexcept {
1443 using Extraction = AggregateFieldNameExtraction;
1444 constexpr StringView NAME = extractAggregateFieldName(getValueDependentFunctionName<Reference{
get<Index>(
getFields(getDummyValue<std::remove_cvref_t<Aggregate>>()))}>(),
1445 Extraction::PREFIX, Extraction::SUFFIX);
1446 if (std::is_constant_evaluated()) {
1450 static constexpr ConstantString<char, NAME.size()> RESULT = NAME;
1455[[nodiscard]]
constexpr StringView extractEnumerandFieldName(
StringView name,
size_t offset,
size_t suffixLength) {
1456 name.remove_prefix(offset);
1457 name.remove_suffix(suffixLength);
1458 name.remove_prefix(name.rfind(
':') + 1);
1462template <std::
size_t Index,
typename Enum>
1463[[nodiscard]]
constexpr StringView getEnumerandNameAt() noexcept {
1464 using Extraction = EnumerandNameExtraction;
1465 constexpr StringView NAME = extractEnumerandFieldName(getValueDependentFunctionName<std::remove_cvref_t<Enum>{Index}>(), Extraction::OFFSET, Extraction::SUFFIX_LENGTH);
1466 if (std::is_constant_evaluated()) {
1470 static constexpr ConstantString<char, NAME.size()> RESULT = NAME;
1477 std::size_t myField123;
1480enum TestEnum :
int {
1485enum class TestEnumClass :
int {
1490template <
typename Target,
typename Object>
1491[[nodiscard]]
consteval Target getMemberPointerTarget(Target Object::*)
noexcept;
1493template <
typename Target,
typename Object>
1494[[nodiscard]]
consteval Object getMemberPointerObject(Target Object::*)
noexcept;
1499template <
typename T>
1500struct unqualified_type_name {
1502 using type = unqualified_type_name;
1504 static constexpr StringView value = detail::getUnqualifiedTypeName<T>();
1506 constexpr operator value_type() const noexcept {
1510 [[nodiscard]]
constexpr value_type operator()() const noexcept {
1525template <
typename T>
1538template <std::
size_t Index, aggregate Aggregate>
1540struct aggregate_field_name {
1542 using type = aggregate_field_name;
1544 static constexpr StringView value = detail::getAggregateFieldName<Index, Aggregate>();
1546 constexpr operator value_type() const noexcept {
1550 [[nodiscard]]
constexpr value_type operator()() const noexcept {
1567template <std::
size_t Index,
typename Aggregate>
1591template <
typename Aggregate>
1615template <
typename Aggregate>
1641template <
typename Aggregate>
1663template <
typename Aggregate>
1665 using A = std::remove_cvref_t<Aggregate>;
1666 auto&& fields =
getFields(std::forward<Aggregate>(value));
1689template <
typename Aggregate>
1691 using A = std::remove_cvref_t<Aggregate>;
1692 auto&& fields =
getFields(std::forward<Aggregate>(value));
1699template <std::
size_t Index, enumeration Enum>
1700struct enumerand_name_at {
1702 using type = enumerand_name_at;
1704 static constexpr StringView value = detail::getEnumerandNameAt<Index, Enum>();
1706 constexpr operator value_type() const noexcept {
1710 [[nodiscard]]
constexpr value_type operator()() const noexcept {
1724template <std::
size_t Index,
typename Enum>
1734template <auto Enumerand>
1735struct enumerand_name {
1736 static_assert(
enumeration<
decltype(Enumerand)>,
"enumerand_name argument must be a value of an enum type.");
1739template <auto Enumerand>
1740requires enumeration<
decltype(Enumerand)>
1741struct enumerand_name<Enumerand> : enumerand_name_at<static_cast<size_t>(static_cast<std::underlying_type_t<decltype(Enumerand)>>(Enumerand)), decltype(Enumerand)> {};
1743template <auto Enumerand>
1744requires enumeration<std::remove_cvref_t<
decltype(
decltype(Enumerand)::value)>>
struct enumerand_name<Enumerand> : enumerand_name<decltype(Enumerand)::value> {};
1752template <auto Enumerand>
1769template <
typename Enum, std::
size_t I>
1770[[nodiscard]]
constexpr std::size_t getEnumSize() noexcept {
1772 return getEnumSize<Enum, I + 1>();
1781template <enumeration Enum>
1782struct enum_size : std::integral_constant<std::size_t, detail::getEnumSize<Enum, 0>()> {};
1791template <
typename Enum>
1816template <enumeration Enum>
1834template <enumeration Enum>
1836 [fn]<std::size_t... Indices>(std::index_sequence<Indices...>) ->
void {
1837 (fn(
CONSTANT<Enum{Indices}>), ...);
1838 }(std::make_index_sequence<enum_size_v<Enum>>{});
1856template <enumeration Enum>
1858 [fn]<std::size_t... Indices>(std::index_sequence<Indices...>) ->
void {
1860 }(std::make_index_sequence<enum_size_v<Enum>>{});
1877template <enumeration Enum>
1879 [fn]<std::size_t... Indices>(std::index_sequence<Indices...>) ->
void {
1881 }(std::make_index_sequence<enum_size_v<Enum>>{});
1900template <enumeration Enum>
1902 [fn]<std::size_t... Indices>(std::index_sequence<Indices...>) ->
void {
1904 }(std::make_index_sequence<enum_size_v<Enum>>{});
1920template <enumeration Enum>
1926template <auto Member>
1927struct member_pointer_target_type {
1928 using type =
decltype(detail::getMemberPointerTarget(Member));
1937template <auto Member>
1941template <auto Member>
1942struct member_pointer_object_type {
1943 using type =
decltype(detail::getMemberPointerObject(Member));
1952template <auto Member>
1957template <auto Member>
1958[[nodiscard]]
constexpr size_t getMemberPointerIndex()
noexcept {
1960 const auto dummyFields =
getFields(getDummyValue<Object>());
1961 const auto dummyMemberPointer = &(getDummyValue<Object>().*Member);
1965 if (&
get<index>(dummyFields) == dummyMemberPointer) {
1976template <auto Member>
1977struct member_pointer_index : std::integral_constant<size_t, detail::getMemberPointerIndex<Member>()> {};
1987template <auto Member>
1994template <
typename Function>
1995struct function_parameter_types {
1996 using type =
decltype(detail::getFunctionParameterTypes(std::declval<Function>()));
2005template <
typename Function>
2009template <
typename Function>
2010struct function_return_type {
2011 using type =
decltype(detail::getFunctionReturnType(std::declval<Function>()));
2020template <
typename Function>
2024template <
typename V>
2025struct variant_alternative_types {
2026 using type =
decltype(detail::getVariantAlternativeTypes(std::declval<V>()));
2035template <
typename V>
2039template <
typename T>
2040struct tuple_element_types {
2041 using type =
decltype(detail::getTupleElementTypes(std::declval<T>()));
2050template <
typename T>
2054template <
typename V>
2055struct tuple_of_variant_alternatives {
2056 using type =
decltype(detail::getTupleOfVariantAlternatives(std::declval<V>()));
2065template <
typename V>
#define GREM_EXPORT
Definition attributes.hpp:43
Definition ConstantString.hpp:40
constexpr size_type size() const noexcept
Definition ConstantString.hpp:127
Definition concepts.hpp:100
Definition concepts.hpp:47
Definition concepts.hpp:144
Definition concepts.hpp:94
Definition concepts.hpp:35
@ U
'u'
Definition keyboard.hpp:91
@ N
'n'
Definition keyboard.hpp:84
@ T
't'
Definition keyboard.hpp:90
@ R
'r'
Definition keyboard.hpp:88
json::ObjectBase< std::allocator > Object
JSON object type using the default allocator.
Definition json.hpp:389
constexpr ComponentSwizzle< 0 > X
Tag specifying the X component at index 0 of a vector.
Definition quantities.hpp:1492
std::function< Signature > Function
Definition Function.hpp:14
constexpr tuple_element_t< Index, Pair< T1, T2 > > & get(Pair< T1, T2 > &t) noexcept
Definition Pair.hpp:202
constexpr Tuple< Ts &... > tie(Ts &... ts)
Definition Tuple.hpp:451
Tuple(Ts...) -> Tuple< Ts... >
ConstantString(const StringLike &str) -> ConstantString< std::remove_cvref_t< decltype(str[0])>, detail::constant_string_length_v< StringLike > >
constexpr Tuple< std::unwrap_ref_decay_t< Ts >... > make_tuple(Ts &&... ts)
Definition Tuple.hpp:446
StringViewBase< char, std::char_traits< char > > StringView
Definition StringView.hpp:16
CStringViewBase< char, std::char_traits< char > > CStringView
Definition CStringView.hpp:635