2022-02-03 08:45:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "CoreTypes.h"
|
|
|
|
|
|
|
|
NAMESPACE_REDCRAFT_BEGIN
|
|
|
|
NAMESPACE_MODULE_BEGIN(Redcraft)
|
|
|
|
NAMESPACE_MODULE_BEGIN(Utility)
|
|
|
|
|
2022-11-16 14:03:54 +00:00
|
|
|
template <typename T> requires (requires(T&& Container) { Container.GetData(); })
|
2022-12-13 14:02:39 +00:00
|
|
|
FORCEINLINE constexpr decltype(auto) GetData(T&& Container)
|
2022-02-03 08:45:34 +00:00
|
|
|
{
|
|
|
|
return Container.GetData();
|
|
|
|
}
|
|
|
|
|
2022-12-13 14:02:39 +00:00
|
|
|
template <typename T, size_t N> FORCEINLINE constexpr T* GetData( T(& Container)[N]) { return Container; }
|
|
|
|
template <typename T, size_t N> FORCEINLINE constexpr T* GetData( T(&& Container)[N]) { return Container; }
|
|
|
|
template <typename T, size_t N> FORCEINLINE constexpr const T* GetData(const T(& Container)[N]) { return Container; }
|
|
|
|
template <typename T, size_t N> FORCEINLINE constexpr const T* GetData(const T(&& Container)[N]) { return Container; }
|
2022-02-03 08:45:34 +00:00
|
|
|
|
2022-11-16 14:03:54 +00:00
|
|
|
template <typename T> requires (requires(T&& Container) { Container.data(); })
|
2022-12-13 14:02:39 +00:00
|
|
|
FORCEINLINE constexpr decltype(auto) GetData(T&& Container)
|
2022-02-03 08:45:34 +00:00
|
|
|
{
|
|
|
|
return Container.data();
|
|
|
|
}
|
|
|
|
|
2022-11-23 15:27:45 +00:00
|
|
|
template <typename T>
|
2022-12-13 14:02:39 +00:00
|
|
|
FORCEINLINE constexpr decltype(auto) GetData(initializer_list<T> Container)
|
2022-11-23 15:27:45 +00:00
|
|
|
{
|
|
|
|
return Container.begin();
|
|
|
|
}
|
|
|
|
|
2022-11-16 14:03:54 +00:00
|
|
|
template <typename T> requires (requires(T&& Container) { Container.Num(); })
|
2022-12-13 14:02:39 +00:00
|
|
|
FORCEINLINE constexpr decltype(auto) GetNum(T&& Container)
|
2022-02-03 08:45:34 +00:00
|
|
|
{
|
|
|
|
return Container.Num();
|
|
|
|
}
|
|
|
|
|
2022-12-13 14:02:39 +00:00
|
|
|
template <typename T, size_t N> FORCEINLINE constexpr size_t GetNum( T(& Container)[N]) { return N; }
|
|
|
|
template <typename T, size_t N> FORCEINLINE constexpr size_t GetNum( T(&& Container)[N]) { return N; }
|
|
|
|
template <typename T, size_t N> FORCEINLINE constexpr size_t GetNum(const T(& Container)[N]) { return N; }
|
|
|
|
template <typename T, size_t N> FORCEINLINE constexpr size_t GetNum(const T(&& Container)[N]) { return N; }
|
2022-02-03 08:45:34 +00:00
|
|
|
|
2022-11-16 14:03:54 +00:00
|
|
|
template <typename T> requires (requires(T&& Container) { Container.size(); })
|
2022-12-13 14:02:39 +00:00
|
|
|
FORCEINLINE constexpr decltype(auto) GetNum(T&& Container)
|
2022-02-03 08:45:34 +00:00
|
|
|
{
|
|
|
|
return Container.size();
|
|
|
|
}
|
|
|
|
|
2022-11-23 15:27:45 +00:00
|
|
|
template <typename T>
|
2022-12-13 14:02:39 +00:00
|
|
|
FORCEINLINE constexpr decltype(auto) GetNum(initializer_list<T> Container)
|
2022-11-23 15:27:45 +00:00
|
|
|
{
|
|
|
|
return Container.size();
|
|
|
|
}
|
|
|
|
|
2022-02-03 08:45:34 +00:00
|
|
|
NAMESPACE_MODULE_END(Utility)
|
|
|
|
NAMESPACE_MODULE_END(Redcraft)
|
|
|
|
NAMESPACE_REDCRAFT_END
|