1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3 Copyright (c) 2006 Tobias Schwinger
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #if !defined(FUSION_PAIR_07222005_1203)
9 #define FUSION_PAIR_07222005_1203
11 #include <boost/fusion/support/config.hpp>
14 #include <boost/fusion/support/detail/access.hpp>
15 #include <boost/fusion/support/detail/as_fusion_element.hpp>
16 #include <boost/config.hpp>
17 #include <boost/utility/enable_if.hpp>
18 #include <boost/type_traits/is_convertible.hpp>
19 #include <boost/type_traits/is_lvalue_reference.hpp>
21 #if defined (BOOST_MSVC)
22 # pragma warning(push)
23 # pragma warning (disable: 4512) // assignment operator could not be generated.
26 namespace boost { namespace fusion
28 // A half runtime pair where the first type does not have data
29 template <typename First, typename Second>
32 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
36 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
38 : second(rhs.second) {}
40 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
41 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
43 : second(BOOST_FUSION_FWD_ELEM(Second, rhs.second)) {}
46 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
47 pair(typename detail::call_param<Second>::type val)
50 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
51 template <typename Second2>
52 BOOST_FUSION_GPU_ENABLED
54 , typename boost::disable_if<is_lvalue_reference<Second2> >::type* /* dummy */ = 0
55 , typename boost::enable_if<is_convertible<Second2, Second> >::type* /*dummy*/ = 0
56 ) : second(BOOST_FUSION_FWD_ELEM(Second, val)) {}
59 template <typename Second2>
60 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
61 pair(pair<First, Second2> const& rhs)
62 : second(rhs.second) {}
64 template <typename Second2>
65 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
66 pair& operator=(pair<First, Second2> const& rhs)
72 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
73 pair& operator=(pair const& rhs)
79 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
80 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
81 pair& operator=(pair&& rhs)
83 second = BOOST_FUSION_FWD_ELEM(Second, rhs.second);
88 typedef First first_type;
89 typedef Second second_type;
95 template<typename First, typename Second>
98 typedef fusion::pair<First,
99 typename detail::as_fusion_element<Second>::type> type;
105 typedef typename Pair::first_type type;
111 typedef typename Pair::second_type type;
115 template <typename First, typename Second>
116 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
117 inline typename result_of::make_pair<First,Second>::type
118 make_pair(Second const& val)
120 return pair<First, typename detail::as_fusion_element<Second>::type>(val);
123 template <typename First, typename Second>
125 operator<<(std::ostream& os, pair<First, Second> const& p)
131 template <typename First, typename Second>
133 operator>>(std::istream& is, pair<First, Second>& p)
139 template <typename First, typename SecondL, typename SecondR>
140 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
142 operator==(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
144 return l.second == r.second;
147 template <typename First, typename SecondL, typename SecondR>
148 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
150 operator!=(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
152 return l.second != r.second;
155 template <typename First, typename SecondL, typename SecondR>
156 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
158 operator<(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
160 return l.second < r.second;
164 #if defined (BOOST_MSVC)
165 # pragma warning(pop)