File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,19 @@ if (NOT USE_CXX_EXCEPTIONS)
114
114
endif ()
115
115
endif ()
116
116
117
+ # /Zc:__cplusplus is required to make __cplusplus accurate
118
+ # /Zc:__cplusplus is available starting with Visual Studio 2017 version 15.7
119
+ # (according to https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus)
120
+ # That version is equivalent to _MSC_VER==1914
121
+ # (according to https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019)
122
+ # CMake's ${MSVC_VERSION} is equivalent to _MSC_VER
123
+ # (according to https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html#variable:MSVC_VERSION)
124
+ # GREATER and EQUAL are used because GREATER_EQUAL is available starting with CMake 3.7
125
+ # (according to https://cmake.org/cmake/help/v3.7/release/3.7.html#commands)
126
+ if ((MSVC ) AND ((MSVC_VERSION GREATER 1914 ) OR (MSVC_VERSION EQUAL 1914 )))
127
+ target_compile_options (Async++ PUBLIC /Zc:__cplusplus )
128
+ endif ()
129
+
117
130
include (CMakePackageConfigHelpers )
118
131
configure_package_config_file ("${CMAKE_CURRENT_LIST_DIR} /Async++Config.cmake.in"
119
132
"${PROJECT_BINARY_DIR} /Async++Config.cmake"
Original file line number Diff line number Diff line change @@ -473,8 +473,14 @@ class local_task {
473
473
};
474
474
475
475
// Spawn a function asynchronously
476
+ #if (__cplusplus >= 201703L)
477
+ // Use std::invoke_result instead of std::result_of for C++17 or greater because std::result_of was deprecated in C++17 and removed in C++20
478
+ template <typename Sched, typename Func>
479
+ task<typename detail::remove_task<std::invoke_result_t <std::decay_t <Func>>>::type> spawn (Sched& sched, Func&& f)
480
+ #else
476
481
template <typename Sched, typename Func>
477
482
task<typename detail::remove_task<typename std::result_of<typename std::decay<Func>::type()>::type>::type> spawn (Sched& sched, Func&& f)
483
+ #endif
478
484
{
479
485
// Using result_of in the function return type to work around bugs in the Intel
480
486
// C++ compiler.
You can’t perform that action at this time.
0 commit comments