| 1 |
// (C) Copyright John Maddock 2010. |
| 2 |
// (C) Copyright Matt Borland 2024. |
| 3 |
// Use, modification and distribution are subject to the |
| 4 |
// Boost Software License, Version 1.0. (See accompanying file |
| 5 |
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 |
|
| 7 |
#ifndef BOOST_MATH_TUPLE_HPP_INCLUDED |
| 8 |
#define BOOST_MATH_TUPLE_HPP_INCLUDED |
| 9 |
|
| 10 |
#include <boost/math/tools/config.hpp> |
| 11 |
|
| 12 |
#ifdef BOOST_MATH_ENABLE_CUDA |
| 13 |
|
| 14 |
#include <boost/math/tools/type_traits.hpp> |
| 15 |
#include <cuda/std/utility> |
| 16 |
#include <cuda/std/tuple> |
| 17 |
|
| 18 |
namespace boost { |
| 19 |
namespace math { |
| 20 |
|
| 21 |
using cuda::std::pair; |
| 22 |
using cuda::std::tuple; |
| 23 |
|
| 24 |
using cuda::std::make_pair; |
| 25 |
|
| 26 |
using cuda::std::tie; |
| 27 |
using cuda::std::get; |
| 28 |
|
| 29 |
using cuda::std::tuple_size; |
| 30 |
using cuda::std::tuple_element; |
| 31 |
|
| 32 |
namespace detail { |
| 33 |
|
| 34 |
template <typename T> |
| 35 |
BOOST_MATH_GPU_ENABLED T&& forward(boost::math::remove_reference_t<T>& arg) noexcept |
| 36 |
{ |
| 37 |
return static_cast<T&&>(arg); |
| 38 |
} |
| 39 |
|
| 40 |
template <typename T> |
| 41 |
BOOST_MATH_GPU_ENABLED T&& forward(boost::math::remove_reference_t<T>&& arg) noexcept |
| 42 |
{ |
| 43 |
static_assert(!boost::math::is_lvalue_reference<T>::value, "Cannot forward an rvalue as an lvalue."); |
| 44 |
return static_cast<T&&>(arg); |
| 45 |
} |
| 46 |
|
| 47 |
} // namespace detail |
| 48 |
|
| 49 |
template <typename T, typename... Ts> |
| 50 |
BOOST_MATH_GPU_ENABLED auto make_tuple(T&& t, Ts&&... ts) |
| 51 |
{ |
| 52 |
return cuda::std::tuple<boost::math::decay_t<T>, boost::math::decay_t<Ts>...>( |
| 53 |
boost::math::detail::forward<T>(t), boost::math::detail::forward<Ts>(ts)... |
| 54 |
); |
| 55 |
} |
| 56 |
|
| 57 |
} // namespace math |
| 58 |
} // namespace boost |
| 59 |
|
| 60 |
#else |
| 61 |
|
| 62 |
#include <tuple> |
| 63 |
|
| 64 |
namespace boost { |
| 65 |
namespace math { |
| 66 |
|
| 67 |
using ::std::tuple; |
| 68 |
using ::std::pair; |
| 69 |
|
| 70 |
// [6.1.3.2] Tuple creation functions |
| 71 |
using ::std::ignore; |
| 72 |
using ::std::make_tuple; |
| 73 |
using ::std::tie; |
| 74 |
using ::std::get; |
| 75 |
|
| 76 |
// [6.1.3.3] Tuple helper classes |
| 77 |
using ::std::tuple_size; |
| 78 |
using ::std::tuple_element; |
| 79 |
|
| 80 |
// Pair helpers |
| 81 |
using ::std::make_pair; |
| 82 |
|
| 83 |
} // namespace math |
| 84 |
} // namespace boost |
| 85 |
|
| 86 |
#endif // BOOST_MATH_ENABLE_CUDA |
| 87 |
|
| 88 |
#endif |