]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/fusion/tuple/tuple.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / fusion / tuple / tuple.hpp
1 /*=============================================================================
2 Copyright (c) 2014-2015 Kohei Takahashi
3
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
9
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/tuple/tuple_fwd.hpp>
12
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>
18 #else
19
20 ///////////////////////////////////////////////////////////////////////////////
21 // C++11 interface
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>
32 #include <utility>
33
34 namespace boost { namespace fusion
35 {
36 template <typename ...T>
37 struct tuple
38 : vector_detail::vector_data<
39 typename detail::make_index_sequence<sizeof...(T)>::type
40 , T...
41 >
42 {
43 typedef vector_detail::vector_data<
44 typename detail::make_index_sequence<sizeof...(T)>::type
45 , T...
46 > base;
47
48 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
49 BOOST_DEFAULTED_FUNCTION(tuple(), {})
50
51 template <
52 typename ...U
53 , typename = typename boost::enable_if_c<
54 sizeof...(U) >= sizeof...(T)
55 >::type
56 >
57 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
58 tuple(tuple<U...> const& other)
59 : base(vector_detail::each_elem(), other) {}
60
61 template <
62 typename ...U
63 , typename = typename boost::enable_if_c<
64 sizeof...(U) >= sizeof...(T)
65 >::type
66 >
67 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
68 tuple(tuple<U...>&& other)
69 : base(vector_detail::each_elem(), std::move(other)) {}
70
71 template <
72 typename ...U
73 , typename = typename boost::enable_if_c<(
74 fusion::detail::and_<is_convertible<U, T>...>::value &&
75 sizeof...(U) >= 1
76 )>::type
77 >
78 /*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED
79 explicit
80 tuple(U&&... args)
81 : base(vector_detail::each_elem(), std::forward<U>(args)...) {}
82
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) {}
87
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)) {}
92
93 template<typename U>
94 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
95 tuple& operator=(U&& rhs)
96 {
97 base::assign_sequence(std::forward<U>(rhs));
98 return *this;
99 }
100 };
101
102 template <typename Tuple>
103 struct tuple_size : result_of::size<Tuple> {};
104
105 template <int N, typename Tuple>
106 struct tuple_element : result_of::value_at_c<Tuple, N> {};
107
108 template <int N, typename Tuple>
109 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
110 inline typename result_of::at_c<Tuple, N>::type
111 get(Tuple& tup)
112 {
113 return at_c<N>(tup);
114 }
115
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)
120 {
121 return at_c<N>(tup);
122 }
123 }}
124
125 #endif
126 #endif
127