File indexing completed on 2025-01-18 09:34:43
0001
0002
0003
0004
0005
0006
0007
0008 #if !defined(FUSION_PAIR_07222005_1203)
0009 #define FUSION_PAIR_07222005_1203
0010
0011 #include <boost/fusion/support/config.hpp>
0012 #include <iosfwd>
0013
0014 #include <boost/fusion/support/detail/access.hpp>
0015 #include <boost/fusion/support/detail/as_fusion_element.hpp>
0016 #include <boost/config.hpp>
0017 #include <boost/utility/enable_if.hpp>
0018 #include <boost/type_traits/is_convertible.hpp>
0019 #include <boost/type_traits/is_lvalue_reference.hpp>
0020
0021 #if defined (BOOST_MSVC)
0022 # pragma warning(push)
0023 # pragma warning (disable: 4512)
0024 #endif
0025
0026 namespace boost { namespace fusion
0027 {
0028
0029 template <typename First, typename Second>
0030 struct pair
0031 {
0032 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0033 pair()
0034 : second() {}
0035
0036 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0037 pair(pair const& rhs)
0038 : second(rhs.second) {}
0039
0040 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0041 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0042 pair(pair&& rhs)
0043 : second(BOOST_FUSION_FWD_ELEM(Second, rhs.second)) {}
0044 #endif
0045
0046 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0047 pair(typename detail::call_param<Second>::type val)
0048 : second(val) {}
0049
0050 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0051 template <typename Second2>
0052 BOOST_FUSION_GPU_ENABLED
0053 pair(Second2&& val
0054 , typename boost::disable_if<is_lvalue_reference<Second2> >::type* = 0
0055 , typename boost::enable_if<is_convertible<Second2, Second> >::type* = 0
0056 ) : second(BOOST_FUSION_FWD_ELEM(Second, val)) {}
0057 #endif
0058
0059 template <typename Second2>
0060 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0061 pair(pair<First, Second2> const& rhs)
0062 : second(rhs.second) {}
0063
0064 template <typename Second2>
0065 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0066 pair& operator=(pair<First, Second2> const& rhs)
0067 {
0068 second = rhs.second;
0069 return *this;
0070 }
0071
0072 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0073 pair& operator=(pair const& rhs)
0074 {
0075 second = rhs.second;
0076 return *this;
0077 }
0078
0079 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0080 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0081 pair& operator=(pair&& rhs)
0082 {
0083 second = BOOST_FUSION_FWD_ELEM(Second, rhs.second);
0084 return *this;
0085 }
0086 #endif
0087
0088 typedef First first_type;
0089 typedef Second second_type;
0090 Second second;
0091 };
0092
0093 namespace result_of
0094 {
0095 template<typename First, typename Second>
0096 struct make_pair
0097 {
0098 typedef fusion::pair<First,
0099 typename detail::as_fusion_element<Second>::type> type;
0100 };
0101
0102 template<class Pair>
0103 struct first
0104 {
0105 typedef typename Pair::first_type type;
0106 };
0107
0108 template<class Pair>
0109 struct second
0110 {
0111 typedef typename Pair::second_type type;
0112 };
0113 }
0114
0115 template <typename First, typename Second>
0116 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0117 inline typename result_of::make_pair<First,Second>::type
0118 make_pair(Second const& val)
0119 {
0120 return pair<First, typename detail::as_fusion_element<Second>::type>(val);
0121 }
0122
0123 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0124 template <typename First, typename Second>
0125 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0126 inline typename result_of::make_pair<First,Second>::type
0127 make_pair(Second&& val)
0128 {
0129 return pair<First, typename detail::as_fusion_element<Second>::type>(
0130 BOOST_FUSION_FWD_ELEM(Second, val));
0131 }
0132 #endif
0133
0134 template <typename First, typename Second>
0135 inline std::ostream&
0136 operator<<(std::ostream& os, pair<First, Second> const& p)
0137 {
0138 os << p.second;
0139 return os;
0140 }
0141
0142 template <typename First, typename Second>
0143 inline std::istream&
0144 operator>>(std::istream& is, pair<First, Second>& p)
0145 {
0146 is >> p.second;
0147 return is;
0148 }
0149
0150 template <typename First, typename SecondL, typename SecondR>
0151 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0152 inline bool
0153 operator==(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
0154 {
0155 return l.second == r.second;
0156 }
0157
0158 template <typename First, typename SecondL, typename SecondR>
0159 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0160 inline bool
0161 operator!=(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
0162 {
0163 return l.second != r.second;
0164 }
0165
0166 template <typename First, typename SecondL, typename SecondR>
0167 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0168 inline bool
0169 operator<(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
0170 {
0171 return l.second < r.second;
0172 }
0173 }}
0174
0175 #if defined (BOOST_MSVC)
0176 # pragma warning(pop)
0177 #endif
0178
0179 #endif