From 155621858078889ec4f976f227742700a8144d4e Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Mon, 15 Jun 2020 14:35:58 -0700 Subject: [PATCH 1/2] std::result_of removed in C++20 --- CMakeLists.txt | 5 +++++ api/include/opentelemetry/nostd/function_ref.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 264d58992d..af4c3dbe30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,11 @@ include(CTest) find_package(Threads) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # Options for Visual C++ compiler + 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) { From d1bd7b284b5325360c2e871e0117abe79118f98e Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Mon, 15 Jun 2020 19:44:09 -0700 Subject: [PATCH 2/2] Update CMakeLists.txt Address code review comment to document what /Zc:__cplusplus option is doing --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af4c3dbe30..2e5eee69e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,9 @@ include(CTest) find_package(Threads) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - # Options for Visual C++ compiler + # 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()