From c4c1430e46fc16068b8a4d92a00a11cf53b69f71 Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Wed, 23 Nov 2022 23:27:45 +0800 Subject: [PATCH] feat(templates): add specialization of GetData and GetNum to initializer_list --- Redcraft.Utility/Source/Public/Templates/Container.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Redcraft.Utility/Source/Public/Templates/Container.h b/Redcraft.Utility/Source/Public/Templates/Container.h index 650e75f..b047074 100644 --- a/Redcraft.Utility/Source/Public/Templates/Container.h +++ b/Redcraft.Utility/Source/Public/Templates/Container.h @@ -23,6 +23,12 @@ constexpr decltype(auto) GetData(T&& Container) return Container.data(); } +template +constexpr decltype(auto) GetData(initializer_list Container) +{ + return Container.begin(); +} + template requires (requires(T&& Container) { Container.Num(); }) constexpr decltype(auto) GetNum(T&& Container) { @@ -40,6 +46,12 @@ constexpr decltype(auto) GetNum(T&& Container) return Container.size(); } +template +constexpr decltype(auto) GetNum(initializer_list Container) +{ + return Container.size(); +} + NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END