Skip to content

Commit 6a10d86

Browse files
committed
Add MSVC support to initializer_list
1 parent db16065 commit 6a10d86

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/EASTL/initializer_list.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
initializer_list() EA_NOEXCEPT // EA_NOEXCEPT requires a recent version of EABase.
5757
: mpArray(NULL), mArraySize(0) { }
5858

59+
#if defined(EA_COMPILER_MSVC)
60+
// MSVC generates constructor calls with two pointers instead of one pointer + size. The constructor is
61+
// public.
62+
// See: https://docs.microsoft.com/en-us/cpp/standard-library/initializer-list-class#initializer_list
63+
initializer_list(const_iterator pFirst, const_iterator pLast) EA_NOEXCEPT
64+
: mpArray(pFirst), mArraySize(pLast - pFirst) { }
65+
#endif
66+
5967
size_type size() const EA_NOEXCEPT { return mArraySize; }
6068
const_iterator begin() const EA_NOEXCEPT { return mpArray; } // Must be const_iterator, as initializer_list (and its mpArray) is an immutable temp object.
6169
const_iterator end() const EA_NOEXCEPT { return mpArray + mArraySize; }

0 commit comments

Comments
 (0)