feat(templates): add specialization of GetData and GetNum to initializer_list

This commit is contained in:
_Redstone_c_ 2022-11-23 23:27:45 +08:00
parent 246965af79
commit c4c1430e46

View File

@ -23,6 +23,12 @@ constexpr decltype(auto) GetData(T&& Container)
return Container.data();
}
template <typename T>
constexpr decltype(auto) GetData(initializer_list<T> Container)
{
return Container.begin();
}
template <typename T> 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 <typename T>
constexpr decltype(auto) GetNum(initializer_list<T> Container)
{
return Container.size();
}
NAMESPACE_MODULE_END(Utility)
NAMESPACE_MODULE_END(Redcraft)
NAMESPACE_REDCRAFT_END