diff --git a/CMakeLists.txt b/CMakeLists.txt index c2ed2b6d80..ee6dcbe380 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,13 @@ include(CTest) find_package(Threads) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # Options for Visual C++ compiler: + # /Zc:__cplusplus - report an updated value for recent C++ language standards. + # Without this option MSVC returns the value of __cplusplus="199711L" + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") +endif() + if(WITH_PROTOBUF) set(protobuf_MODULE_COMPATIBLE ON) find_package(Protobuf CONFIG NAMES protobuf) diff --git a/api/include/opentelemetry/nostd/function_ref.h b/api/include/opentelemetry/nostd/function_ref.h index 33c94d00ab..de61c7040a 100644 --- a/api/include/opentelemetry/nostd/function_ref.h +++ b/api/include/opentelemetry/nostd/function_ref.h @@ -63,7 +63,13 @@ class function_ref typename std::enable_if::type>::value, int>::type = 0, typename std::enable_if< +#if (__cplusplus >= 201703L) + // std::result_of deprecated in C++17, removed in C++20 + std::is_convertible::type, R>::value, +#else + // std::result_of since C++11 std::is_convertible::type, R>::value, +#endif int>::type = 0> function_ref(F &&f) {