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
Bug
MODIFY
cmake/ThrustBuildCompilerTargets.cmake
cmake/ThrustBuildCompilerTargets.cmake
@@ -24,7 +24,10 @@ function(thrust_build_compiler_targets)
endif()
if ("MSVC" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
- # TODO Enable /Wall
+ # TODO Enable /Wall instead of W3
+ append_option_if_available("/W3" cxx_compile_options)
+
+ # Treat all warnings as errors:
append_option_if_available("/WX" cxx_compile_options)
# Disabled loss-of-data conversion warnings.

MODIFY
cmake/ThrustBuildTargetList.cmake
cmake/ThrustBuildTargetList.cmake
@@ -66,6 +66,14 @@ function(thrust_set_target_properties target_name host device dialect prefix)
PROPERTIES
CXX_STANDARD ${dialect}
CUDA_STANDARD ${dialect}
+ # Must manually request that the standards above are actually respected
+ # or else CMake will silently fail to configure the targets correctly...
+ # Note that this doesn't actually work as of CMake 3.16:
+ # https://gitlab.kitware.com/cmake/cmake/-/issues/20953
+ # We'll leave these properties enabled in hopes that they will someday
+ # work.
+ CXX_STANDARD_REQUIRED ON
+ CUDA_STANDARD_REQUIRED ON
ARCHIVE_OUTPUT_DIRECTORY "${THRUST_LIBRARY_OUTPUT_DIR}"
LIBRARY_OUTPUT_DIRECTORY "${THRUST_LIBRARY_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${THRUST_EXECUTABLE_OUTPUT_DIR}"

MODIFY
thrust/iterator/detail/transform_input_output_iterator.inl
thrust/iterator/detail/transform_input_output_iterator.inl
@@ -30,7 +30,14 @@ namespace detail
template <typename InputFunction, typename OutputFunction, typename Iterator>
class transform_input_output_iterator_proxy
{
- using Value = typename std::result_of<InputFunction(typename thrust::iterator_value<Iterator>::type)>::type;
+ using iterator_value_type = typename thrust::iterator_value<Iterator>::type;
+
+ // std::result_of is deprecated in 2017, replace with std::invoke_result
+#if THRUST_CPP_DIALECT < 2017
+ using Value = typename std::result_of<InputFunction(iterator_value_type)>::type;
+#else
+ using Value = std::invoke_result_t<InputFunction, iterator_value_type>;
+#endif
public:
__host__ __device__
@@ -75,11 +82,20 @@ template <typename InputFunction, typename OutputFunction, typename Iterator>
template <typename InputFunction, typename OutputFunction, typename Iterator>
struct transform_input_output_iterator_base
{
+private:
+ using iterator_value_type = typename thrust::iterator_value<Iterator>::type;
+
+public:
typedef thrust::iterator_adaptor
<
transform_input_output_iterator<InputFunction, OutputFunction, Iterator>
, Iterator
- , typename std::result_of<InputFunction(typename thrust::iterator_value<Iterator>::type)>::type
+ // std::result_of is deprecated in 2017, replace with std::invoke_result
+#if THRUST_CPP_DIALECT < 2017
+ , typename std::result_of<InputFunction(iterator_value_type)>::type
+#else
+ , std::invoke_result_t<InputFunction, iterator_value_type>
+#endif
, thrust::use_default
, thrust::use_default
, transform_input_output_iterator_proxy<InputFunction, OutputFunction, Iterator>

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