89 lines · plain
1// (C) Copyright John Maddock 2010.2// (C) Copyright Matt Borland 2024.3// Use, modification and distribution are subject to the4// Boost Software License, Version 1.0. (See accompanying file5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)6 7#ifndef BOOST_MATH_TUPLE_HPP_INCLUDED8#define BOOST_MATH_TUPLE_HPP_INCLUDED9 10#include <boost/math/tools/config.hpp>11 12#ifdef BOOST_MATH_ENABLE_CUDA13 14#include <boost/math/tools/type_traits.hpp>15#include <cuda/std/utility>16#include <cuda/std/tuple>17 18namespace boost { 19namespace math {20 21using cuda::std::pair;22using cuda::std::tuple;23 24using cuda::std::make_pair;25 26using cuda::std::tie;27using cuda::std::get;28 29using cuda::std::tuple_size;30using cuda::std::tuple_element;31 32namespace detail {33 34template <typename T>35BOOST_MATH_GPU_ENABLED T&& forward(boost::math::remove_reference_t<T>& arg) noexcept36{37 return static_cast<T&&>(arg);38}39 40template <typename T>41BOOST_MATH_GPU_ENABLED T&& forward(boost::math::remove_reference_t<T>&& arg) noexcept42{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 detail48 49template <typename T, typename... Ts>50BOOST_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 math58} // namespace boost59 60#else61 62#include <tuple>63 64namespace boost { 65namespace math {66 67using ::std::tuple;68using ::std::pair;69 70// [6.1.3.2] Tuple creation functions71using ::std::ignore;72using ::std::make_tuple;73using ::std::tie;74using ::std::get;75 76// [6.1.3.3] Tuple helper classes77using ::std::tuple_size;78using ::std::tuple_element;79 80// Pair helpers81using ::std::make_pair;82 83} // namespace math84} // namespace boost85 86#endif // BOOST_MATH_ENABLE_CUDA87 88#endif89