From 6a10d8630a65261cc38c8836d7e4f704f728ff27 Mon Sep 17 00:00:00 2001 From: Philipp Kerling Date: Mon, 30 Jan 2023 09:14:38 +0100 Subject: [PATCH] Add MSVC support to initializer_list --- include/EASTL/initializer_list.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/EASTL/initializer_list.h b/include/EASTL/initializer_list.h index 028fb4f8..f79b7162 100644 --- a/include/EASTL/initializer_list.h +++ b/include/EASTL/initializer_list.h @@ -56,6 +56,14 @@ initializer_list() EA_NOEXCEPT // EA_NOEXCEPT requires a recent version of EABase. : mpArray(NULL), mArraySize(0) { } +#if defined(EA_COMPILER_MSVC) + // MSVC generates constructor calls with two pointers instead of one pointer + size. The constructor is + // public. + // See: https://docs.microsoft.com/en-us/cpp/standard-library/initializer-list-class#initializer_list + initializer_list(const_iterator pFirst, const_iterator pLast) EA_NOEXCEPT + : mpArray(pFirst), mArraySize(pLast - pFirst) { } +#endif + size_type size() const EA_NOEXCEPT { return mArraySize; } const_iterator begin() const EA_NOEXCEPT { return mpArray; } // Must be const_iterator, as initializer_list (and its mpArray) is an immutable temp object. const_iterator end() const EA_NOEXCEPT { return mpArray + mArraySize; }