refactor(templates): fix the return value derivation of GetData and GetNum
This commit is contained in:
parent
018d3afb73
commit
ecbf6480ac
@ -7,7 +7,7 @@ NAMESPACE_MODULE_BEGIN(Redcraft)
|
|||||||
NAMESPACE_MODULE_BEGIN(Utility)
|
NAMESPACE_MODULE_BEGIN(Utility)
|
||||||
|
|
||||||
template <typename T> requires requires(T&& Container) { Container.GetData(); }
|
template <typename T> requires requires(T&& Container) { Container.GetData(); }
|
||||||
constexpr auto GetData(T&& Container)
|
constexpr decltype(auto) GetData(T&& Container)
|
||||||
{
|
{
|
||||||
return Container.GetData();
|
return Container.GetData();
|
||||||
}
|
}
|
||||||
@ -18,13 +18,13 @@ template <typename T, size_t N> constexpr const T* GetData(const T(& Container)
|
|||||||
template <typename T, size_t N> constexpr const T* GetData(const T(&& Container)[N]) { return Container; }
|
template <typename T, size_t N> constexpr const T* GetData(const T(&& Container)[N]) { return Container; }
|
||||||
|
|
||||||
template <typename T> requires requires(T&& Container) { Container.data(); }
|
template <typename T> requires requires(T&& Container) { Container.data(); }
|
||||||
constexpr auto GetData(T&& Container)
|
constexpr decltype(auto) GetData(T&& Container)
|
||||||
{
|
{
|
||||||
return Container.data();
|
return Container.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> requires requires(T&& Container) { Container.Num(); }
|
template <typename T> requires requires(T&& Container) { Container.Num(); }
|
||||||
constexpr auto GetNum(T&& Container)
|
constexpr decltype(auto) GetNum(T&& Container)
|
||||||
{
|
{
|
||||||
return Container.Num();
|
return Container.Num();
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ template <typename T, size_t N> constexpr size_t GetNum(const T(& Container)[N]
|
|||||||
template <typename T, size_t N> constexpr size_t GetNum(const T(&& Container)[N]) { return N; }
|
template <typename T, size_t N> constexpr size_t GetNum(const T(&& Container)[N]) { return N; }
|
||||||
|
|
||||||
template <typename T> requires requires(T&& Container) { Container.size(); }
|
template <typename T> requires requires(T&& Container) { Container.size(); }
|
||||||
constexpr auto GetNum(T&& Container)
|
constexpr decltype(auto) GetNum(T&& Container)
|
||||||
{
|
{
|
||||||
return Container.size();
|
return Container.size();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user