1 /*=============================================================================
2 Copyright (c) 2014-2015 Kohei Takahashi
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #ifndef FUSION_TUPLE_14122014_0102
8 #define FUSION_TUPLE_14122014_0102
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/tuple/tuple_fwd.hpp>
13 ///////////////////////////////////////////////////////////////////////////////
14 // With no variadics, we will use the C++03 version
15 ///////////////////////////////////////////////////////////////////////////////
16 #if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE)
17 # include <boost/fusion/tuple/detail/tuple.hpp>
20 ///////////////////////////////////////////////////////////////////////////////
22 ///////////////////////////////////////////////////////////////////////////////
23 #include <boost/core/enable_if.hpp>
24 #include <boost/fusion/container/vector/vector.hpp>
25 #include <boost/fusion/sequence/intrinsic/size.hpp>
26 #include <boost/fusion/sequence/intrinsic/value_at.hpp>
27 #include <boost/fusion/sequence/intrinsic/at.hpp>
28 #include <boost/fusion/sequence/comparison.hpp>
29 #include <boost/fusion/sequence/io.hpp>
30 #include <boost/fusion/support/detail/and.hpp>
31 #include <boost/type_traits/is_convertible.hpp>
34 namespace boost { namespace fusion
36 template <typename ...T>
37 struct tuple : vector<T...>
39 typedef vector<T...> base_type;
41 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
47 , typename = typename boost::enable_if_c<
48 sizeof...(U) >= sizeof...(T)
51 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
52 tuple(tuple<U...> const& other)
57 , typename = typename boost::enable_if_c<
58 sizeof...(U) >= sizeof...(T)
61 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
62 tuple(tuple<U...>&& other)
63 : base_type(std::move(other)) {}
67 , typename = typename boost::enable_if_c<(
68 fusion::detail::and_<is_convertible<U, T>...>::value &&
72 /*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED
75 : base_type(std::forward<U>(args)...) {}
77 template<typename U1, typename U2>
78 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
79 tuple(std::pair<U1, U2> const& other)
80 : base_type(other.first, other.second) {}
82 template<typename U1, typename U2>
83 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
84 tuple(std::pair<U1, U2>&& other)
85 : base_type(std::move(other.first), std::move(other.second)) {}
88 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
89 tuple& operator=(U&& rhs)
91 base_type::operator=(std::forward<U>(rhs));
96 template <typename Tuple>
97 struct tuple_size : result_of::size<Tuple> {};
99 template <int N, typename Tuple>
100 struct tuple_element : result_of::value_at_c<Tuple, N> {};
102 template <int N, typename Tuple>
103 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
104 inline typename result_of::at_c<Tuple, N>::type
110 template <int N, typename Tuple>
111 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
112 inline typename result_of::at_c<Tuple const, N>::type
113 get(Tuple const& tup)