1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Tobias Schwinger
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(FUSION_PAIR_07222005_1203)
#define FUSION_PAIR_07222005_1203
#include <boost/fusion/support/config.hpp>
#include <iosfwd>
#include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/support/detail/as_fusion_element.hpp>
#include <boost/config.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_lvalue_reference.hpp>
#if defined (BOOST_MSVC)
# pragma warning(push)
# pragma warning (disable: 4512) // assignment operator could not be generated.
#endif
namespace boost { namespace fusion
{
// A half runtime pair where the first type does not have data
template <typename First, typename Second>
struct pair
{
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair()
: second() {}
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(pair const& rhs)
: second(rhs.second) {}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(pair&& rhs)
: second(BOOST_FUSION_FWD_ELEM(Second, rhs.second)) {}
#endif
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(typename detail::call_param<Second>::type val)
: second(val) {}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template <typename Second2>
BOOST_FUSION_GPU_ENABLED
pair(Second2&& val
, typename boost::disable_if<is_lvalue_reference<Second2> >::type* /* dummy */ = 0
, typename boost::enable_if<is_convertible<Second2, Second> >::type* /*dummy*/ = 0
) : second(BOOST_FUSION_FWD_ELEM(Second, val)) {}
#endif
template <typename Second2>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(pair<First, Second2> const& rhs)
: second(rhs.second) {}
template <typename Second2>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair& operator=(pair<First, Second2> const& rhs)
{
second = rhs.second;
return *this;
}
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair& operator=(pair const& rhs)
{
second = rhs.second;
return *this;
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair& operator=(pair&& rhs)
{
second = BOOST_FUSION_FWD_ELEM(Second, rhs.second);
return *this;
}
#endif
typedef First first_type;
typedef Second second_type;
Second second;
};
namespace result_of
{
template<typename First, typename Second>
struct make_pair
{
typedef fusion::pair<First,
typename detail::as_fusion_element<Second>::type> type;
};
template<class Pair>
struct first
{
typedef typename Pair::first_type type;
};
template<class Pair>
struct second
{
typedef typename Pair::second_type type;
};
}
template <typename First, typename Second>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::make_pair<First,Second>::type
make_pair(Second const& val)
{
return pair<First, typename detail::as_fusion_element<Second>::type>(val);
}
template <typename First, typename Second>
inline std::ostream&
operator<<(std::ostream& os, pair<First, Second> const& p)
{
os << p.second;
return os;
}
template <typename First, typename Second>
inline std::istream&
operator>>(std::istream& is, pair<First, Second>& p)
{
is >> p.second;
return is;
}
template <typename First, typename SecondL, typename SecondR>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline bool
operator==(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
{
return l.second == r.second;
}
template <typename First, typename SecondL, typename SecondR>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline bool
operator!=(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
{
return l.second != r.second;
}
template <typename First, typename SecondL, typename SecondR>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline bool
operator<(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
{
return l.second < r.second;
}
}}
#if defined (BOOST_MSVC)
# pragma warning(pop)
#endif
#endif
|