From ecbf6480ac70da7fcca661b1eeb0a1d64ca25d3c Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Tue, 19 Apr 2022 22:53:23 +0800 Subject: [PATCH] refactor(templates): fix the return value derivation of GetData and GetNum --- Redcraft.Utility/Source/Public/Templates/Container.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Redcraft.Utility/Source/Public/Templates/Container.h b/Redcraft.Utility/Source/Public/Templates/Container.h index d711579..f58743a 100644 --- a/Redcraft.Utility/Source/Public/Templates/Container.h +++ b/Redcraft.Utility/Source/Public/Templates/Container.h @@ -7,7 +7,7 @@ NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) template 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 constexpr const T* GetData(const T(& Container) template constexpr const T* GetData(const T(&& Container)[N]) { return Container; } template requires requires(T&& Container) { Container.data(); } -constexpr auto GetData(T&& Container) +constexpr decltype(auto) GetData(T&& Container) { return Container.data(); } template 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 constexpr size_t GetNum(const T(& Container)[N] template constexpr size_t GetNum(const T(&& Container)[N]) { return N; } template requires requires(T&& Container) { Container.size(); } -constexpr auto GetNum(T&& Container) +constexpr decltype(auto) GetNum(T&& Container) { return Container.size(); }