From 7ef03cec5c87362e60d00c5027416ae639f87020 Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Sat, 1 Mar 2025 01:51:25 +0100 Subject: [PATCH] Drop obsolete thrust tuple algorithms (#3966) --- thrust/testing/tuple_algorithms.cu | 55 ----------------- thrust/thrust/detail/raw_reference_cast.h | 2 + thrust/thrust/detail/tuple_algorithms.h | 75 ----------------------- 3 files changed, 2 insertions(+), 130 deletions(-) delete mode 100644 thrust/testing/tuple_algorithms.cu delete mode 100644 thrust/thrust/detail/tuple_algorithms.h diff --git a/thrust/testing/tuple_algorithms.cu b/thrust/testing/tuple_algorithms.cu deleted file mode 100644 index 2d650e923fa..00000000000 --- a/thrust/testing/tuple_algorithms.cu +++ /dev/null @@ -1,55 +0,0 @@ -#include - -#include -#include - -#include - -// FIXME: Replace with C++14 style `thrust::square<>` when we have it. -struct custom_square -{ - template - _CCCL_HOST_DEVICE T operator()(T v) const - { - return v * v; - } -}; - -struct custom_square_inplace -{ - template - _CCCL_HOST_DEVICE void operator()(T& v) const - { - v *= v; - } -}; - -void test_tuple_subset() -{ - auto t0 = std::make_tuple(0, 2, 3.14); - - auto t1 = thrust::tuple_subset(t0, thrust::index_sequence<2, 0>{}); - - ASSERT_EQUAL_QUIET(t1, std::make_tuple(3.14, 0)); -} -DECLARE_UNITTEST(test_tuple_subset); - -void test_tuple_transform() -{ - auto t0 = std::make_tuple(0, 2, 3.14); - - auto t1 = thrust::tuple_transform(t0, custom_square{}); - - ASSERT_EQUAL_QUIET(t1, std::make_tuple(0, 4, 9.8596)); -} -DECLARE_UNITTEST(test_tuple_transform); - -void test_tuple_for_each() -{ - auto t = std::make_tuple(0, 2, 3.14); - - thrust::tuple_for_each(t, custom_square_inplace{}); - - ASSERT_EQUAL_QUIET(t, std::make_tuple(0, 4, 9.8596)); -} -DECLARE_UNITTEST(test_tuple_for_each); diff --git a/thrust/thrust/detail/raw_reference_cast.h b/thrust/thrust/detail/raw_reference_cast.h index d49585a30e8..20c536e7b91 100644 --- a/thrust/thrust/detail/raw_reference_cast.h +++ b/thrust/thrust/detail/raw_reference_cast.h @@ -25,10 +25,12 @@ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) # pragma system_header #endif // no system header + #include #include #include #include +#include // the order of declarations and definitions in this file is totally goofy // this header defines raw_reference_cast, which has a few overloads towards the bottom of the file diff --git a/thrust/thrust/detail/tuple_algorithms.h b/thrust/thrust/detail/tuple_algorithms.h deleted file mode 100644 index dfb9daf289a..00000000000 --- a/thrust/thrust/detail/tuple_algorithms.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2008-2013 NVIDIA Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) -# pragma GCC system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) -# pragma clang system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) -# pragma system_header -#endif // no system header -#include -#include - -#include - -THRUST_NAMESPACE_BEGIN - -template -auto tuple_subset(Tuple&& t, index_sequence) - THRUST_DECLTYPE_RETURNS(std::make_tuple(std::get(THRUST_FWD(t))...)); - -namespace detail -{ - -template -void tuple_for_each_impl(Tuple&& t, F&& f, index_sequence) -{ - auto l = {(f(std::get(t)), 0)...}; - THRUST_UNUSED_VAR(l); -} - -template -auto tuple_transform_impl(Tuple&& t, F&& f, index_sequence) - THRUST_DECLTYPE_RETURNS(std::make_tuple(f(std::get(t))...)); - -} // namespace detail - -template -auto tuple_for_each(std::tuple& t, F&& f) - THRUST_DECLTYPE_RETURNS(detail::tuple_for_each_impl(t, THRUST_FWD(f), make_index_sequence{})); -template -auto tuple_for_each(std::tuple const& t, F&& f) - THRUST_DECLTYPE_RETURNS(detail::tuple_for_each_impl(t, THRUST_FWD(f), make_index_sequence{})); -template -auto tuple_for_each(std::tuple&& t, F&& f) THRUST_DECLTYPE_RETURNS( - detail::tuple_for_each_impl(std::move(t), THRUST_FWD(f), make_index_sequence{})); - -template -auto tuple_transform(std::tuple& t, F&& f) - THRUST_DECLTYPE_RETURNS(detail::tuple_transform_impl(t, THRUST_FWD(f), make_index_sequence{})); -template -auto tuple_transform(std::tuple const& t, F&& f) - THRUST_DECLTYPE_RETURNS(detail::tuple_transform_impl(t, THRUST_FWD(f), make_index_sequence{})); -template -auto tuple_transform(std::tuple&& t, F&& f) THRUST_DECLTYPE_RETURNS( - detail::tuple_transform_impl(std::move(t), THRUST_FWD(f), make_index_sequence{})); - -THRUST_NAMESPACE_END