From adf62c31843c94bc5bbb3531bfe66a28ca9ee3be Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Thu, 31 Dec 2020 03:46:53 +0100 Subject: [PATCH] Fix compilation with MSVC 19. --- CMakeLists.txt | 7 +++++++ src/support/RandomAccessList.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91dd05a547..65d3a6e06e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1069,6 +1069,13 @@ if(MSVC) set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Zc:wchar_t-") endif() + if (MSVC_VERSION GREATER_EQUAL 1914) + # Ensure the __cplusplus macro is set to a sensible value. + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Zc:__cplusplus") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zc:__cplusplus") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Zc:__cplusplus") + endif() + message(STATUS "----- Warning level : ${CMAKE_CXX_WARNING_LEVEL} ${WARNING_LEVEL_MESSAGE}") message(STATUS "----- Warnings as errors : ${MSVC_W_ERROR}") message(STATUS "----- Warnings disabled : ${MSVC_W_DISABLE}") diff --git a/src/support/RandomAccessList.h b/src/support/RandomAccessList.h index 0eaa52a480..644fee68ae 100644 --- a/src/support/RandomAccessList.h +++ b/src/support/RandomAccessList.h @@ -296,7 +296,7 @@ public: const_iterator iterator_at(size_t i) const { - return (i == size()) ? end() : iterCont_[i]; + return (i == size()) ? end() : const_iterator(iterCont_[i]); } iterator iterator_at(size_t i)