Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Simulation/Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(MICROSOFT_QUANTUM_SIMULATOR_VERSION $ENV{ASSEMBLY_VERSION})
set(MICROSOFT_QUANTUM_VERSION_STRING "quarcsw simulator version ${MICROSOFT_QUANTUM_SIMULATOR_VERSION}")
MESSAGE(STATUS "QUARCSW version: ${MICROSOFT_QUANTUM_SIMULATOR_VERSION}")

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
Expand Down
15 changes: 10 additions & 5 deletions src/Simulation/Native/src/SafeInt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ Please read the leading comments before using the class.
#define CPLUSPLUS_STD CPLUSPLUS_98
#elif __cplusplus < 201402L
#define CPLUSPLUS_STD CPLUSPLUS_11
#else
#elif __cplusplus < 201703L
#define CPLUSPLUS_STD CPLUSPLUS_14
#else
#define CPLUSPLUS_STD CPLUSPLUS_17
#endif

#elif SAFEINT_COMPILER == VISUAL_STUDIO_COMPILER
Expand All @@ -60,10 +62,13 @@ Please read the leading comments before using the class.
#elif _MSC_VER < 1910 // VS 2015
#define CPLUSPLUS_STD CPLUSPLUS_11

#else // VS 2017 or later
#elif _MSC_VER < 1926 // VS 2017
#define CPLUSPLUS_STD CPLUSPLUS_14

#else // VS 2019 or later
// Note - there is a __cpp_constexpr test now, but everything prior to VS 2017 reports incorrect values
// and this version always supports at least the CPLUSPLUS_14 approach
#define CPLUSPLUS_STD CPLUSPLUS_14
#define CPLUSPLUS_STD CPLUSPLUS_17

#endif

Expand All @@ -72,8 +77,8 @@ Please read the leading comments before using the class.
#define CPLUSPLUS_STD CPLUSPLUS_98
#endif // Determine C++ support level

#if (SAFEINT_COMPILER == CLANG_COMPILER || SAFEINT_COMPILER == GCC_COMPILER) && CPLUSPLUS_STD < CPLUSPLUS_11
#error Must compile with --std=c++11, preferably --std=c++14 to use constexpr improvements
#if (SAFEINT_COMPILER == CLANG_COMPILER || SAFEINT_COMPILER == GCC_COMPILER) && CPLUSPLUS_STD < CPLUSPLUS_17
#error Must compile with --std=c++17
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this changes the build requirement for clang and gcc to C++17, where previously this file would have accepted and attempted to handle anything down to C++11. That said, the CMakeLists.txt for all the code under src\Native already had C++14 as the required standard, so I don't believe our support of C++11 was genuine here. Given that after this switch we will start incorporating C++17 only features, it felt appropriate to update this requirement too.

#endif

#define CONSTEXPR_NONE 0
Expand Down