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>
38 : vector_detail::vector_data<
39 typename detail::make_index_sequence<sizeof...(T)>::type
43 typedef vector_detail::vector_data<
44 typename detail::make_index_sequence<sizeof...(T)>::type
48 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
49 BOOST_DEFAULTED_FUNCTION(tuple(), {})
53 , typename = typename boost::enable_if_c<
54 sizeof...(U) >= sizeof...(T)
57 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
58 tuple(tuple<U...> const& other)
59 : base(vector_detail::each_elem(), other) {}
63 , typename = typename boost::enable_if_c<
64 sizeof...(U) >= sizeof...(T)
67 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
68 tuple(tuple<U...>&& other)
69 : base(vector_detail::each_elem(), std::move(other)) {}
73 , typename = typename boost::enable_if_c<(
74 fusion::detail::and_<is_convertible<U, T>...>::value &&
78 /*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED
81 : base(vector_detail::each_elem(), std::forward<U>(args)...) {}
83 template<typename U1, typename U2>
84 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
85 tuple(std::pair<U1, U2> const& other)
86 : base(vector_detail::each_elem(), other.first, other.second) {}
88 template<typename U1, typename U2>
89 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
90 tuple(std::pair<U1, U2>&& other)
91 : base(vector_detail::each_elem(), std::move(other.first), std::move(other.second)) {}
94 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
95 tuple& operator=(U&& rhs)
97 base::assign_sequence(std::forward<U>(rhs));
102 template <typename Tuple>
103 struct tuple_size : result_of::size<Tuple> {};
105 template <int N, typename Tuple>
106 struct tuple_element : result_of::value_at_c<Tuple, N> {};
108 template <int N, typename Tuple>
109 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
110 inline typename result_of::at_c<Tuple, N>::type
116 template <int N, typename Tuple>
117 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
118 inline typename result_of::at_c<Tuple const, N>::type
119 get(Tuple const& tup)