diff --git a/Redcraft.Utility/Source/Public/Templates/IntegerSequence.h b/Redcraft.Utility/Source/Public/Templates/IntegerSequence.h new file mode 100644 index 0000000..84a2706 --- /dev/null +++ b/Redcraft.Utility/Source/Public/Templates/IntegerSequence.h @@ -0,0 +1,66 @@ +#pragma once + +#include "CoreTypes.h" + +NAMESPACE_REDCRAFT_BEGIN +NAMESPACE_MODULE_BEGIN(Redcraft) +NAMESPACE_MODULE_BEGIN(Utility) + +template +struct TIntegerSequence +{ + using ValueType = T; + static constexpr size_t Size() { return sizeof...(Ints); } +}; + +NAMESPACE_PRIVATE_BEGIN + +#ifdef _MSC_VER + +template +struct TMakeIntegerSequence +{ + using Type = typename __make_integer_seq; +}; + +#elif __has_builtin(__make_integer_seq) + +template +struct TMakeIntegerSequence +{ + using Type = typename __make_integer_seq; +}; + +#else + +template +struct TMakeIntegerSequence +{ + using Type = typename TMakeIntegerSequence::Type; +}; + +template +struct TMakeIntegerSequence<0, T, Ints...> +{ + using Type = TIntegerSequence; +}; + +#endif + +NAMESPACE_PRIVATE_END + +template +using TIndexSequence = TIntegerSequence; + +template +using TMakeIntegerSequence = typename NAMESPACE_PRIVATE::TMakeIntegerSequence::Type; + +template +using TMakeIndexSequence = TMakeIntegerSequence; + +template +using TIndexSequenceFor = TMakeIndexSequence; + +NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) +NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Templates/Templates.h b/Redcraft.Utility/Source/Public/Templates/Templates.h index 5024671..d18d47c 100644 --- a/Redcraft.Utility/Source/Public/Templates/Templates.h +++ b/Redcraft.Utility/Source/Public/Templates/Templates.h @@ -9,3 +9,4 @@ #include "Templates/Optional.h" #include "Templates/Variant.h" #include "Templates/Any.h" +#include "Templates/IntegerSequence.h"