Skip to content

Commit 107c23b

Browse files
committed
Foundation: Fix type constraints for Span<T> std::initializer_list constructor
1 parent f7e2426 commit 107c23b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Libraries/Foundation/Span.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ struct Span
3131
// clang-format off
3232
using SizeType = size_t;
3333
using VoidType = typename TypeTraits::SameConstnessAs<Type, void>::type;
34-
template <typename U> using TypeIfNotVoid = typename TypeTraits::EnableIf<not TypeTraits::IsSame<U, VoidType>::value, Type>::type;
34+
template <typename U> using TypeIfNotVoid = typename TypeTraits::EnableIf<not TypeTraits::IsSame<U, VoidType>::value, Type>::type;
35+
template <typename U> using TypeInitializerList = typename TypeTraits::EnableIf<TypeTraits::IsConst<U>::value and not TypeTraits::IsSame<U, VoidType>::value, Type>::type;
3536
template <typename U> using SameType = TypeTraits::IsSame<typename TypeTraits::RemoveConst<U>::type, typename TypeTraits::RemoveConst<Type>::type>;
3637
template <typename U> using EnableNotVoid = typename TypeTraits::EnableIf<SameType<U>::value and not TypeTraits::IsSame<U, VoidType>::value, bool>::type;
3738
// clang-format on
@@ -60,7 +61,7 @@ struct Span
6061
/// @brief Span specialized constructor (mainly used for converting const char* to StringView)
6162
/// @param list an initializer list of elements
6263
template <typename U = Type>
63-
constexpr Span(std::initializer_list<TypeIfNotVoid<U>> list) : items(nullptr), sizeElements(0)
64+
constexpr Span(std::initializer_list<TypeInitializerList<U>> list) : items(nullptr), sizeElements(0)
6465
{
6566
// We need this two step initialization to avoid warnings on all compilers
6667
items = list.begin();

0 commit comments

Comments
 (0)