VS2017的C++17特性默認並未開啟,需要在編譯參數中手動開啟。找到項目的CMakeLists.txt,在查找編譯器的代碼后面加入如下內容即可。
if (MSVC_VERSION GREATER_EQUAL "1900") include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("/std:c++latest" _cpp_latest_flag_supported) if (_cpp_latest_flag_supported) add_compile_options("/std:c++latest") endif() endif()