Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit 7676470

Browse files
committed
Non-backportable C++17 fixes.
These affect files that aren't in the 1.9.10-1 branch. - Enable /W3 on Windows to catch deprecation warnings. - Enabled the `CUDA_STANDARD_REQUIRED` property. - Replace std::result_of with std::invoke_result. Fixes #1214 Bug 200619424
1 parent 862bc53 commit 7676470

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

cmake/ThrustBuildCompilerTargets.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ function(thrust_build_compiler_targets)
2424
endif()
2525

2626
if ("MSVC" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
27-
# TODO Enable /Wall
27+
# TODO Enable /Wall instead of W3
28+
append_option_if_available("/W3" cxx_compile_options)
29+
30+
# Treat all warnings as errors:
2831
append_option_if_available("/WX" cxx_compile_options)
2932

3033
# Disabled loss-of-data conversion warnings.

cmake/ThrustBuildTargetList.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ function(thrust_set_target_properties target_name host device dialect prefix)
6666
PROPERTIES
6767
CXX_STANDARD ${dialect}
6868
CUDA_STANDARD ${dialect}
69+
# Must manually request that the standards above are actually respected
70+
# or else CMake will silently fail to configure the targets correctly...
71+
# Note that this doesn't actually work as of CMake 3.16:
72+
# https://gitlab.kitware.com/cmake/cmake/-/issues/20953
73+
# We'll leave these properties enabled in hopes that they will someday
74+
# work.
75+
CXX_STANDARD_REQUIRED ON
76+
CUDA_STANDARD_REQUIRED ON
6977
ARCHIVE_OUTPUT_DIRECTORY "${THRUST_LIBRARY_OUTPUT_DIR}"
7078
LIBRARY_OUTPUT_DIRECTORY "${THRUST_LIBRARY_OUTPUT_DIR}"
7179
RUNTIME_OUTPUT_DIRECTORY "${THRUST_EXECUTABLE_OUTPUT_DIR}"

thrust/iterator/detail/transform_input_output_iterator.inl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ namespace detail
3030
template <typename InputFunction, typename OutputFunction, typename Iterator>
3131
class transform_input_output_iterator_proxy
3232
{
33-
using Value = typename std::result_of<InputFunction(typename thrust::iterator_value<Iterator>::type)>::type;
33+
using iterator_value_type = typename thrust::iterator_value<Iterator>::type;
34+
35+
// std::result_of is deprecated in 2017, replace with std::invoke_result
36+
#if THRUST_CPP_DIALECT < 2017
37+
using Value = typename std::result_of<InputFunction(iterator_value_type)>::type;
38+
#else
39+
using Value = std::invoke_result_t<InputFunction, iterator_value_type>;
40+
#endif
3441

3542
public:
3643
__host__ __device__
@@ -75,11 +82,20 @@ template <typename InputFunction, typename OutputFunction, typename Iterator>
7582
template <typename InputFunction, typename OutputFunction, typename Iterator>
7683
struct transform_input_output_iterator_base
7784
{
85+
private:
86+
using iterator_value_type = typename thrust::iterator_value<Iterator>::type;
87+
88+
public:
7889
typedef thrust::iterator_adaptor
7990
<
8091
transform_input_output_iterator<InputFunction, OutputFunction, Iterator>
8192
, Iterator
82-
, typename std::result_of<InputFunction(typename thrust::iterator_value<Iterator>::type)>::type
93+
// std::result_of is deprecated in 2017, replace with std::invoke_result
94+
#if THRUST_CPP_DIALECT < 2017
95+
, typename std::result_of<InputFunction(iterator_value_type)>::type
96+
#else
97+
, std::invoke_result_t<InputFunction, iterator_value_type>
98+
#endif
8399
, thrust::use_default
84100
, thrust::use_default
85101
, transform_input_output_iterator_proxy<InputFunction, OutputFunction, Iterator>

0 commit comments

Comments
 (0)