refactor(templates): fix the return value derivation of GetData and GetNum

This commit is contained in:
_Redstone_c_ 2022-04-19 22:53:23 +08:00
parent 018d3afb73
commit ecbf6480ac
1 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,7 @@ NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility)
template <typename T> requires requires(T&& Container) { Container.GetData(); }
constexpr auto GetData(T&& Container)
constexpr decltype(auto) GetData(T&& Container)
{
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> requires requires(T&& Container) { Container.data(); }
constexpr auto GetData(T&& Container)
constexpr decltype(auto) GetData(T&& Container)
{
return Container.data();
}
template <typename T> requires requires(T&& Container) { Container.Num(); }
constexpr auto GetNum(T&& Container)
constexpr decltype(auto) GetNum(T&& Container)
{
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> requires requires(T&& Container) { Container.size(); }
constexpr auto GetNum(T&& Container)
constexpr decltype(auto) GetNum(T&& Container)
{
return Container.size();
}