From 57f1495b0bf0ec5a7240119830741613f0557653 Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Fri, 7 Feb 2025 18:55:10 +0100 Subject: [PATCH] Drop thrust::identity --- .../api_docs/function_objects/predefined.rst | 1 - thrust/testing/functional.cu | 37 ------------- thrust/testing/transform_iterator.cu | 37 ------------- thrust/testing/type_traits.cu | 19 ++----- thrust/thrust/functional.h | 53 ------------------- .../iterator/detail/transform_iterator.inl | 12 ----- 6 files changed, 5 insertions(+), 154 deletions(-) diff --git a/docs/thrust/api_docs/function_objects/predefined.rst b/docs/thrust/api_docs/function_objects/predefined.rst index fc66bab71d3..290acc5944b 100644 --- a/docs/thrust/api_docs/function_objects/predefined.rst +++ b/docs/thrust/api_docs/function_objects/predefined.rst @@ -7,6 +7,5 @@ Users are encouraged to use the standard C++ function objects available from `` - - :cpp:struct:`thrust::identity ` - :cpp:struct:`thrust::project1st ` - :cpp:struct:`thrust::project2nd ` diff --git a/thrust/testing/functional.cu b/thrust/testing/functional.cu index 02b481be2ac..bdaa54b5d81 100644 --- a/thrust/testing/functional.cu +++ b/thrust/testing/functional.cu @@ -187,43 +187,6 @@ typename ::cuda::std::add_const<_Tp>::type& as_const(_Tp& __t) noexcept return __t; } -// Ad-hoc testing for other functionals -THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestIdentityFunctional() -{ - _CCCL_SUPPRESS_DEPRECATED_PUSH - int i = 42; - double d = 3.14; - - // pass through - ASSERT_EQUAL(thrust::identity{}(i), 42); - ASSERT_EQUAL(thrust::identity{}(d), 3); - - // modification through - thrust::identity{}(i) = 1337; - ASSERT_EQUAL(i, 1337); - - // value categories and const - static_assert(::cuda::std::is_same{}(42)), int&&>::value, ""); - static_assert(::cuda::std::is_same{}(i)), int&>::value, ""); - static_assert(::cuda::std::is_same{}(as_const(i))), const int&>::value, ""); - static_assert(::cuda::std::is_same{}(::cuda::std::move(i))), int&&>::value, ""); - static_assert(::cuda::std::is_same{}(static_cast(i))), const int&>::value, - ""); - - // value categories when casting to different type - static_assert(::cuda::std::is_same{}(3.14)), int&&>::value, ""); - // unfortunately, old versions of MSVC or nvcc in MSVC mode pick the `const int&` overload instead of `int&&` -#if !_CCCL_COMPILER(MSVC, <, 19, 29) && !(_CCCL_COMPILER(MSVC) && _CCCL_CUDA_COMPILER(NVCC, <, 12, 1)) - static_assert(::cuda::std::is_same{}(d)), int&&>::value, ""); - static_assert(::cuda::std::is_same{}(as_const(d))), int&&>::value, ""); -#endif - static_assert(::cuda::std::is_same{}(::cuda::std::move(d))), int&&>::value, ""); - static_assert(::cuda::std::is_same{}(static_cast(d))), int&&>::value, - ""); - _CCCL_SUPPRESS_DEPRECATED_POP -} -DECLARE_UNITTEST(TestIdentityFunctional); - template THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestIdentityFunctionalVector() { diff --git a/thrust/testing/transform_iterator.cu b/thrust/testing/transform_iterator.cu index ee3f710ef2c..4d26225d7e5 100644 --- a/thrust/testing/transform_iterator.cu +++ b/thrust/testing/transform_iterator.cu @@ -1,10 +1,3 @@ -#include - -#if _CCCL_COMPILER(NVHPC) -// suppress warnings on thrust::identity -_CCCL_SUPPRESS_DEPRECATED_PUSH -#endif // _CCCL_COMPILER(NVHPC) - #include #include #include @@ -18,10 +11,6 @@ _CCCL_SUPPRESS_DEPRECATED_PUSH #include -#if _CCCL_COMPILER(NVHPC) -_CCCL_SUPPRESS_DEPRECATED_POP -#endif // _CCCL_COMPILER(NVHPC) - template void TestTransformIterator() { @@ -146,7 +135,6 @@ struct forward void TestTransformIteratorReferenceAndValueType() { - _CCCL_SUPPRESS_DEPRECATED_PUSH using ::cuda::std::is_same; using ::cuda::std::negate; { @@ -171,11 +159,6 @@ void TestTransformIteratorReferenceAndValueType() static_assert(is_same::value, ""); (void) it_tr_fwd; - auto it_tr_tid = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_tid; - auto it_tr_cid = thrust::make_transform_iterator(it, cuda::std::identity{}); static_assert(is_same::value, ""); // special handling by // transform_iterator_reference @@ -205,11 +188,6 @@ void TestTransformIteratorReferenceAndValueType() static_assert(is_same::value, ""); (void) it_tr_fwd; - auto it_tr_tid = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_tid; - auto it_tr_cid = thrust::make_transform_iterator(it, cuda::std::identity{}); static_assert(is_same::value, ""); // special handling by // transform_iterator_reference @@ -239,37 +217,22 @@ void TestTransformIteratorReferenceAndValueType() static_assert(is_same::value, ""); (void) it_tr_fwd; - auto it_tr_ide = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_ide; - - auto it_tr_tid = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_tid; - auto it_tr_cid = thrust::make_transform_iterator(it, cuda::std::identity{}); static_assert(is_same::value, ""); // special handling by // transform_iterator_reference static_assert(is_same::value, ""); (void) it_tr_cid; } - _CCCL_SUPPRESS_DEPRECATED_POP } DECLARE_UNITTEST(TestTransformIteratorReferenceAndValueType); void TestTransformIteratorIdentity() { - _CCCL_SUPPRESS_DEPRECATED_PUSH thrust::device_vector v(3, 42); - ASSERT_EQUAL(*thrust::make_transform_iterator(v.begin(), thrust::identity{}), 42); - ASSERT_EQUAL(*thrust::make_transform_iterator(v.begin(), thrust::identity<>{}), 42); ASSERT_EQUAL(*thrust::make_transform_iterator(v.begin(), cuda::std::identity{}), 42); using namespace thrust::placeholders; ASSERT_EQUAL(*thrust::make_transform_iterator(v.begin(), _1), 42); - _CCCL_SUPPRESS_DEPRECATED_POP } DECLARE_UNITTEST(TestTransformIteratorIdentity); diff --git a/thrust/testing/type_traits.cu b/thrust/testing/type_traits.cu index bbb1989d8d1..d865d0e7767 100644 --- a/thrust/testing/type_traits.cu +++ b/thrust/testing/type_traits.cu @@ -38,23 +38,14 @@ void TestIsContiguousIterator() using HostIteratorTuple = thrust::tuple; - using ConstantIterator = thrust::constant_iterator; - using CountingIterator = thrust::counting_iterator; - _CCCL_SUPPRESS_DEPRECATED_PUSH - using TransformIterator1 = thrust::transform_iterator, HostVector::iterator>; - _CCCL_SUPPRESS_DEPRECATED_POP - using TransformIterator2 = thrust::transform_iterator; - using ZipIterator = thrust::zip_iterator; + using ConstantIterator = thrust::constant_iterator; + using CountingIterator = thrust::counting_iterator; + using TransformIterator = thrust::transform_iterator; + using ZipIterator = thrust::zip_iterator; ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); -#if !_CCCL_COMPILER(NVHPC) - // thrust::identity creates a deprecated warning that could not be worked around - _CCCL_SUPPRESS_DEPRECATED_PUSH - ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); - _CCCL_SUPPRESS_DEPRECATED_POP -#endif // !_CCCL_COMPILER(NVHPC) - ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); + ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); } DECLARE_UNITTEST(TestIsContiguousIterator); diff --git a/thrust/thrust/functional.h b/thrust/thrust/functional.h index eb87d7c6ccb..b851b2a35ab 100644 --- a/thrust/thrust/functional.h +++ b/thrust/thrust/functional.h @@ -151,59 +151,6 @@ using ::cuda::std::bit_xor; * \{ */ -/*! \p identity is a Unary Function that represents the identity function: it takes - * a single argument \c x, and returns \c x. - * - * \tparam T No requirements on \p T. - * - * The following code snippet demonstrates that \p identity returns its - * argument. - * - * \code - * #include - * #include - * ... - * int x = 137; - * thrust::identity id; - * assert(x == id(x)); - * \endcode - * - * \see https://en.cppreference.com/w/cpp/utility/functional/identity - */ -// TODO(bgruber): this version can also act as a functor casting to T making it not equivalent to ::cuda::std::identity -template -struct CCCL_DEPRECATED_BECAUSE("use cuda::std::identity instead") identity -{ - using result_type _LIBCUDACXX_DEPRECATED_IN_CXX11 = T; - - _CCCL_EXEC_CHECK_DISABLE - _CCCL_HOST_DEVICE constexpr const T& operator()(const T& x) const - { - return x; - } - - _CCCL_EXEC_CHECK_DISABLE - _CCCL_HOST_DEVICE constexpr T& operator()(T& x) const - { - return x; - } - - // we cannot add an overload for `const T&&` because then calling e.g. `thrust::identity{}(3.14);` is ambiguous - // on MSVC - - _CCCL_EXEC_CHECK_DISABLE - _CCCL_HOST_DEVICE constexpr T&& operator()(T&& x) const - { - return _CUDA_VSTD::move(x); - } -}; - -_CCCL_SUPPRESS_DEPRECATED_PUSH -template <> -struct CCCL_DEPRECATED_BECAUSE("use cuda::std::identity instead") identity : ::cuda::std::__identity -{}; -_CCCL_SUPPRESS_DEPRECATED_POP - using ::cuda::maximum; using ::cuda::minimum; diff --git a/thrust/thrust/iterator/detail/transform_iterator.inl b/thrust/thrust/iterator/detail/transform_iterator.inl index f01df472f2d..ac2513c9c23 100644 --- a/thrust/thrust/iterator/detail/transform_iterator.inl +++ b/thrust/thrust/iterator/detail/transform_iterator.inl @@ -50,18 +50,6 @@ struct transform_iterator_reference // for certain function objects, we need to tweak the reference type. Notably, identity functions must decay to values. // See the implementation of transform_iterator<...>::dereference() for several comments on why this is necessary. -_CCCL_SUPPRESS_DEPRECATED_PUSH -template -struct transform_iterator_reference, Iterator> -{ - using type = T; -}; -template -struct transform_iterator_reference, Iterator> -{ - using type = iterator_value_t; -}; -_CCCL_SUPPRESS_DEPRECATED_POP template struct transform_iterator_reference<::cuda::std::identity, Iterator> {