diff --git a/thrust/thrust/functional.h b/thrust/thrust/functional.h index 1f4d37eb8d9..0a491097667 100644 --- a/thrust/thrust/functional.h +++ b/thrust/thrust/functional.h @@ -48,225 +48,12 @@ THRUST_NAMESPACE_BEGIN * \{ */ -#define THRUST_BINARY_FUNCTOR_VOID_SPECIALIZATION(func, impl) \ - template <> \ - struct func \ - { \ - using is_transparent = void; \ - _CCCL_EXEC_CHECK_DISABLE \ - template \ - _CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const noexcept(noexcept(impl)) -> decltype(impl) \ - { \ - return impl; \ - } \ - } - -/*! \p plus is a function object. Specifically, it is an Adaptable Binary Function. - * If \c f is an object of class plus, and \c x and \c y are objects - * of class \c T, then f(x,y) returns x+y. - * - * \tparam T is a model of Assignable, - * and if \c x and \c y are objects of type \p T, then x+y must be defined and must have a return type - * that is convertible to \c T. - * - * The following code snippet demonstrates how to use plus to sum two - * device_vectors of \c floats. - * - * \code - * #include - * #include - * #include - * #include - * #include - * ... - * const int N = 1000; - * thrust::device_vector V1(N); - * thrust::device_vector V2(N); - * thrust::device_vector V3(N); - * - * thrust::sequence(V1.begin(), V1.end(), 1); - * thrust::fill(V2.begin(), V2.end(), 75); - * - * thrust::transform(V1.begin(), V1.end(), V2.begin(), V3.begin(), - * thrust::plus()); - * // V3 is now {76, 77, 78, ..., 1075} - * \endcode - * - * \see https://en.cppreference.com/w/cpp/utility/functional/plus - */ -using ::cuda::std::plus; - -/*! \p minus is a function object. Specifically, it is an Adaptable Binary Function. - * If \c f is an object of class minus, and \c x and \c y are objects - * of class \c T, then f(x,y) returns x-y. - * - * \tparam T is a model of Assignable, - * and if \c x and \c y are objects of type \p T, then x-y must be defined and must have a return type - * that is convertible to \c T. - * - * The following code snippet demonstrates how to use minus to subtract - * a device_vector of \c floats from another. - * - * \code - * #include - * #include - * #include - * #include - * #include - * ... - * const int N = 1000; - * thrust::device_vector V1(N); - * thrust::device_vector V2(N); - * thrust::device_vector V3(N); - * - * thrust::sequence(V1.begin(), V1.end(), 1); - * thrust::fill(V2.begin(), V2.end(), 75); - * - * thrust::transform(V1.begin(), V1.end(), V2.begin(), V3.begin(), - * thrust::minus()); - * // V3 is now {-74, -73, -72, ..., 925} - * \endcode - * - * \see https://en.cppreference.com/w/cpp/utility/functional/minus - */ -using ::cuda::std::minus; - -/*! \p multiplies is a function object. Specifically, it is an Adaptable Binary Function. - * If \c f is an object of class multiplies, and \c x and \c y are objects - * of class \c T, then f(x,y) returns x*y. - * - * \tparam T is a model of Assignable, - * and if \c x and \c y are objects of type \p T, then x*y must be defined and must have a return type - * that is convertible to \c T. - * - * The following code snippet demonstrates how to use multiplies to multiply - * two device_vectors of \c floats. - * - * \code - * #include - * #include - * #include - * #include - * #include - * ... - * const int N = 1000; - * thrust::device_vector V1(N); - * thrust::device_vector V2(N); - * thrust::device_vector V3(N); - * - * thrust::sequence(V1.begin(), V1.end(), 1); - * thrust::fill(V2.begin(), V2.end(), 75); - * - * thrust::transform(V1.begin(), V1.end(), V2.begin(), V3.begin(), - * thrust::multiplies()); - * // V3 is now {75, 150, 225, ..., 75000} - * \endcode - * - * \see https://en.cppreference.com/w/cpp/utility/functional/multiplies - */ -using ::cuda::std::multiplies; - -/*! \p divides is a function object. Specifically, it is an Adaptable Binary Function. - * If \c f is an object of class divides, and \c x and \c y are objects - * of class \c T, then f(x,y) returns x/y. - * - * \tparam T is a model of Assignable, - * and if \c x and \c y are objects of type \p T, then x/y must be defined and must have a return type - * that is convertible to \c T. - * - * The following code snippet demonstrates how to use divides to divide - * one device_vectors of \c floats by another. - * - * \code - * #include - * #include - * #include - * #include - * #include - * ... - * const int N = 1000; - * thrust::device_vector V1(N); - * thrust::device_vector V2(N); - * thrust::device_vector V3(N); - * - * thrust::sequence(V1.begin(), V1.end(), 1); - * thrust::fill(V2.begin(), V2.end(), 75); - * - * thrust::transform(V1.begin(), V1.end(), V2.begin(), V3.begin(), - * thrust::divides()); - * // V3 is now {1/75, 2/75, 3/75, ..., 1000/75} - * \endcode - * - * \see https://en.cppreference.com/w/cpp/utility/functional/divides - */ using ::cuda::std::divides; - -/*! \p modulus is a function object. Specifically, it is an Adaptable Binary Function. - * If \c f is an object of class modulus, and \c x and \c y are objects - * of class \c T, then f(x,y) returns x \% y. - * - * \tparam T is a model of Assignable, - * and if \c x and \c y are objects of type \p T, then x \% y must be defined and must have a return - * type that is convertible to \c T. - * - * The following code snippet demonstrates how to use modulus to take - * the modulus of one device_vectors of \c floats by another. - * - * \code - * #include - * #include - * #include - * #include - * #include - * ... - * const int N = 1000; - * thrust::device_vector V1(N); - * thrust::device_vector V2(N); - * thrust::device_vector V3(N); - * - * thrust::sequence(V1.begin(), V1.end(), 1); - * thrust::fill(V2.begin(), V2.end(), 75); - * - * thrust::transform(V1.begin(), V1.end(), V2.begin(), V3.begin(), - * thrust::modulus()); - * // V3 is now {1%75, 2%75, 3%75, ..., 1000%75} - * \endcode - * - * \see https://en.cppreference.com/w/cpp/utility/functional/modulus - */ +using ::cuda::std::minus; using ::cuda::std::modulus; - -/*! \p negate is a function object. Specifically, it is an Adaptable Unary Function. - * If \c f is an object of class negate, and \c x is an object - * of class \c T, then f(x) returns -x. - * - * \tparam T is a model of Assignable, - * and if \c x is an object of type \p T, then -x must be defined and must have a return type that is - * convertible to \c T. - * - * The following code snippet demonstrates how to use negate to negate - * the elements of a device_vector of \c floats. - * - * \code - * #include - * #include - * #include - * #include - * ... - * const int N = 1000; - * thrust::device_vector V1(N); - * thrust::device_vector V2(N); - * - * thrust::sequence(V1.begin(), V1.end(), 1); - * - * thrust::transform(V1.begin(), V1.end(), V2.begin(), - * thrust::negate()); - * // V2 is now {-1, -2, -3, ..., -1000} - * \endcode - * - * \see https://en.cppreference.com/w/cpp/utility/functional/negate - */ +using ::cuda::std::multiplies; using ::cuda::std::negate; +using ::cuda::std::plus; /*! \p square is a function object. Specifically, it is an Adaptable Unary Function. * If \c f is an object of class square, and \c x is an object @@ -327,83 +114,12 @@ struct square * \{ */ -/*! \p equal_to is a function object. Specifically, it is an Adaptable Binary - * Predicate, which means it is a function object that tests the truth or falsehood - * of some condition. If \c f is an object of class equal_to and \c x - * and \c y are objects of class \c T, then f(x,y) returns \c true if - * x == y and \c false otherwise. - * - * \tparam T is a model of Equality - * Comparable. - * - * \see https://en.cppreference.com/w/cpp/utility/functional/equal_to - */ using ::cuda::std::equal_to; - -/*! \p not_equal_to is a function object. Specifically, it is an Adaptable Binary - * Predicate, which means it is a function object that tests the truth or falsehood - * of some condition. If \c f is an object of class not_equal_to and \c x - * and \c y are objects of class \c T, then f(x,y) returns \c true if - * x != y and \c false otherwise. - * - * \tparam T is a model of Equality - * Comparable. - * - * \see https://en.cppreference.com/w/cpp/utility/functional/not_equal_to - */ -using ::cuda::std::not_equal_to; - -/*! \p greater is a function object. Specifically, it is an Adaptable Binary - * Predicate, which means it is a function object that tests the truth or falsehood - * of some condition. If \c f is an object of class greater and \c x - * and \c y are objects of class \c T, then f(x,y) returns \c true if - * x > y and \c false otherwise. - * - * \tparam T is a model of LessThan - * Comparable. - * - * \see https://en.cppreference.com/w/cpp/utility/functional/greater - */ using ::cuda::std::greater; - -/*! \p less is a function object. Specifically, it is an Adaptable Binary - * Predicate, which means it is a function object that tests the truth or falsehood - * of some condition. If \c f is an object of class less and \c x - * and \c y are objects of class \c T, then f(x,y) returns \c true if - * x < y and \c false otherwise. - * - * \tparam T is a model of LessThan - * Comparable. - * - * \see https://en.cppreference.com/w/cpp/utility/functional/less - */ -using ::cuda::std::less; - -/*! \p greater_equal is a function object. Specifically, it is an Adaptable Binary - * Predicate, which means it is a function object that tests the truth or falsehood - * of some condition. If \c f is an object of class greater_equal and \c x - * and \c y are objects of class \c T, then f(x,y) returns \c true if - * x >= y and \c false otherwise. - * - * \tparam T is a model of LessThan - * Comparable. - * - * \see https://en.cppreference.com/w/cpp/utility/functional/greater_equal - */ using ::cuda::std::greater_equal; - -/*! \p less_equal is a function object. Specifically, it is an Adaptable Binary - * Predicate, which means it is a function object that tests the truth or falsehood - * of some condition. If \c f is an object of class less_equal and \c x - * and \c y are objects of class \c T, then f(x,y) returns \c true if - * x <= y and \c false otherwise. - * - * \tparam T is a model of LessThan - * Comparable. - * - * \see https://en.cppreference.com/w/cpp/utility/functional/less_equal - */ +using ::cuda::std::less; using ::cuda::std::less_equal; +using ::cuda::std::not_equal_to; /*! \} */ @@ -413,55 +129,9 @@ using ::cuda::std::less_equal; * \{ */ -/*! \p logical_and is a function object. Specifically, it is an Adaptable Binary Predicate, - * which means it is a function object that tests the truth or falsehood of some condition. - * If \c f is an object of class logical_and and \c x and \c y are objects of - * class \c T (where \c T is convertible to \c bool) then f(x,y) returns \c true - * if and only if both \c x and \c y are \c true. - * - * \tparam T must be convertible to \c bool. - * - * \see https://en.cppreference.com/w/cpp/utility/functional/logical_and - */ using ::cuda::std::logical_and; - -/*! \p logical_or is a function object. Specifically, it is an Adaptable Binary Predicate, - * which means it is a function object that tests the truth or falsehood of some condition. - * If \c f is an object of class logical_or and \c x and \c y are objects of - * class \c T (where \c T is convertible to \c bool) then f(x,y) returns \c true - * if and only if either \c x or \c y are \c true. - * - * \tparam T must be convertible to \c bool. - * - * \see https://en.cppreference.com/w/cpp/utility/functional/logical_or - */ -using ::cuda::std::logical_or; - -/*! \p logical_not is a function object. Specifically, it is an Adaptable Predicate, - * which means it is a function object that tests the truth or falsehood of some condition. - * If \c f is an object of class logical_not and \c x is an object of - * class \c T (where \c T is convertible to \c bool) then f(x) returns \c true - * if and only if \c x is \c false. - * - * \tparam T must be convertible to \c bool. - * - * The following code snippet demonstrates how to use \p logical_not to transform - * a device_vector of \c bools into its logical complement. - * - * \code - * #include - * #include - * #include - * ... - * thrust::device_vector V; - * ... - * thrust::transform(V.begin(), V.end(), V.begin(), thrust::logical_not()); - * // The elements of V are now the logical complement of what they were prior - * \endcode - * - * \see https://en.cppreference.com/w/cpp/utility/functional/logical_not - */ using ::cuda::std::logical_not; +using ::cuda::std::logical_or; /*! \} */ @@ -471,103 +141,8 @@ using ::cuda::std::logical_not; * \{ */ -/*! \p bit_and is a function object. Specifically, it is an Adaptable Binary Function. - * If \c f is an object of class bit_and, and \c x and \c y are objects - * of class \c T, then f(x,y) returns x&y. - * - * \tparam T is a model of Assignable, - * and if \c x and \c y are objects of type \p T, then x&y must be defined and must have a return type - * that is convertible to \c T. - * - * The following code snippet demonstrates how to use bit_and to take - * the bitwise AND of one device_vector of \c ints by another. - * - * \code - * #include - * #include - * #include - * #include - * #include - * ... - * const int N = 1000; - * thrust::device_vector V1(N); - * thrust::device_vector V2(N); - * thrust::device_vector V3(N); - * - * thrust::sequence(V1.begin(), V1.end(), 1); - * thrust::fill(V2.begin(), V2.end(), 13); - * - * thrust::transform(V1.begin(), V1.end(), V2.begin(), V3.begin(), - * thrust::bit_and()); - * // V3 is now {1&13, 2&13, 3&13, ..., 1000%13} - * \endcode - */ using ::cuda::std::bit_and; - -/*! \p bit_or is a function object. Specifically, it is an Adaptable Binary Function. - * If \c f is an object of class bit_and, and \c x and \c y are objects - * of class \c T, then f(x,y) returns x|y. - * - * \tparam T is a model of Assignable, - * and if \c x and \c y are objects of type \p T, then x|y must be defined and must have a return type - * that is convertible to \c T. - * - * The following code snippet demonstrates how to use bit_or to take - * the bitwise OR of one device_vector of \c ints by another. - * - * \code - * #include - * #include - * #include - * #include - * #include - * ... - * const int N = 1000; - * thrust::device_vector V1(N); - * thrust::device_vector V2(N); - * thrust::device_vector V3(N); - * - * thrust::sequence(V1.begin(), V1.end(), 1); - * thrust::fill(V2.begin(), V2.end(), 13); - * - * thrust::transform(V1.begin(), V1.end(), V2.begin(), V3.begin(), - * thrust::bit_or()); - * // V3 is now {1|13, 2|13, 3|13, ..., 1000|13} - * \endcode - */ using ::cuda::std::bit_or; - -/*! \p bit_xor is a function object. Specifically, it is an Adaptable Binary Function. - * If \c f is an object of class bit_and, and \c x and \c y are objects - * of class \c T, then f(x,y) returns x^y. - * - * \tparam T is a model of Assignable, - * and if \c x and \c y are objects of type \p T, then x^y must be defined and must have a return type - * that is convertible to \c T. - * - * The following code snippet demonstrates how to use bit_xor to take - * the bitwise XOR of one device_vector of \c ints by another. - * - * \code - * #include - * #include - * #include - * #include - * #include - * ... - * const int N = 1000; - * thrust::device_vector V1(N); - * thrust::device_vector V2(N); - * thrust::device_vector V3(N); - * - * thrust::sequence(V1.begin(), V1.end(), 1); - * thrust::fill(V2.begin(), V2.end(), 13); - * - * thrust::transform(V1.begin(), V1.end(), V2.begin(), V3.begin(), - * thrust::bit_xor()); - * // V3 is now {1^13, 2^13, 3^13, ..., 1000^13} - * \endcode - */ using ::cuda::std::bit_xor; /*! \} @@ -627,56 +202,7 @@ template <> struct identity : ::cuda::std::__identity {}; -/*! \p maximum is a function object that takes two arguments and returns the greater - * of the two. Specifically, it is an Adaptable Binary Function. If \c f is an - * object of class maximum and \c x and \c y are objects of class \c T - * f(x,y) returns \c x if x > y and \c y, otherwise. - * - * \tparam T is a model of LessThan - * Comparable. - * - * The following code snippet demonstrates that \p maximum returns its - * greater argument. - * - * \code - * #include - * #include - * ... - * int x = 137; - * int y = -137; - * thrust::maximum mx; - * assert(x == mx(x,y)); - * \endcode - * - * \see minimum - * \see min - */ using ::cuda::maximum; - -/*! \p minimum is a function object that takes two arguments and returns the lesser - * of the two. Specifically, it is an Adaptable Binary Function. If \c f is an - * object of class minimum and \c x and \c y are objects of class \c T - * f(x,y) returns \c x if x < y and \c y, otherwise. - * - * \tparam T is a model of LessThan - * Comparable. - * - * The following code snippet demonstrates that \p minimum returns its - * lesser argument. - * - * \code - * #include - * #include - * ... - * int x = 137; - * int y = -137; - * thrust::minimum mn; - * assert(y == mn(x,y)); - * \endcode - * - * \see maximum - * \see max - */ using ::cuda::minimum; /*! \p project1st is a function object that takes two arguments and returns @@ -870,8 +396,6 @@ THRUST_INLINE_CONSTANT thrust::detail::functional::placeholder<9>::type _10; /*! \} // placeholder_objects */ -#undef THRUST_BINARY_FUNCTOR_VOID_SPECIALIZATION - THRUST_NAMESPACE_END #include