]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/fusion/include/boost/fusion/tuple/tuple.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / fusion / include / boost / fusion / tuple / tuple.hpp
CommitLineData
7c673cae
FG
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
34namespace boost { namespace fusion
35{
36 template <typename ...T>
37 struct tuple : vector<T...>
38 {
39 typedef vector<T...> base_type;
40
41 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
42 tuple()
43 : base_type() {}
44
45 template <
46 typename ...U
47 , typename = typename boost::enable_if_c<
48 sizeof...(U) >= sizeof...(T)
49 >::type
50 >
51 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
52 tuple(tuple<U...> const& other)
53 : base_type(other) {}
54
55 template <
56 typename ...U
57 , typename = typename boost::enable_if_c<
58 sizeof...(U) >= sizeof...(T)
59 >::type
60 >
61 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
62 tuple(tuple<U...>&& other)
63 : base_type(std::move(other)) {}
64
65 template <
66 typename ...U
67 , typename = typename boost::enable_if_c<(
68 fusion::detail::and_<is_convertible<U, T>...>::value &&
69 sizeof...(U) >= 1
70 )>::type
71 >
72 /*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED
73 explicit
74 tuple(U&&... args)
75 : base_type(std::forward<U>(args)...) {}
76
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) {}
81
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)) {}
86
87 template<typename U>
88 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
89 tuple& operator=(U&& rhs)
90 {
91 base_type::operator=(std::forward<U>(rhs));
92 return *this;
93 }
94 };
95
96 template <typename Tuple>
97 struct tuple_size : result_of::size<Tuple> {};
98
99 template <int N, typename Tuple>
100 struct tuple_element : result_of::value_at_c<Tuple, N> {};
101
102 template <int N, typename Tuple>
103 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
104 inline typename result_of::at_c<Tuple, N>::type
105 get(Tuple& tup)
106 {
107 return at_c<N>(tup);
108 }
109
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)
114 {
115 return at_c<N>(tup);
116 }
117}}
118
119#endif
120#endif
121