1 ///////////////////////////////////////////////////////////////////////////////
3 /// Proto callables for things found in the std \<utility\> header
5 // Copyright 2010 Eric Niebler. Distributed under the Boost
6 // Software License, Version 1.0. (See accompanying file
7 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 #ifndef BOOST_PROTO_FUNCTIONAL_STD_UTILITY_HPP_EAN_11_27_2010
10 #define BOOST_PROTO_FUNCTIONAL_STD_UTILITY_HPP_EAN_11_27_2010
13 #include <boost/type_traits/remove_const.hpp>
14 #include <boost/type_traits/remove_reference.hpp>
15 #include <boost/proto/proto_fwd.hpp>
17 namespace boost { namespace proto { namespace functional
19 /// \brief A PolymorphicFunctionObject type that invokes the
20 /// \c std::make_pair() algorithm on its arguments.
22 /// A PolymorphicFunctionObject type that invokes the
23 /// \c std::make_pair() algorithm on its arguments.
26 BOOST_PROTO_CALLABLE()
28 template<typename Sig>
31 template<typename This, typename First, typename Second>
32 struct result<This(First, Second)>
36 typename remove_const<typename remove_reference<First>::type>::type
37 , typename remove_const<typename remove_reference<Second>::type>::type
42 template<typename First, typename Second>
43 std::pair<First, Second> operator()(First const &first, Second const &second) const
45 return std::make_pair(first, second);
49 /// \brief A PolymorphicFunctionObject type that returns
50 /// the first element of a std::pair.
52 /// A PolymorphicFunctionObject type that returns
53 /// the first element of a std::pair..
56 BOOST_PROTO_CALLABLE()
58 template<typename Sig>
61 template<typename This, typename Pair>
62 struct result<This(Pair)>
64 typedef typename Pair::first_type type;
67 template<typename This, typename Pair>
68 struct result<This(Pair &)>
70 typedef typename Pair::first_type &type;
73 template<typename This, typename Pair>
74 struct result<This(Pair const &)>
76 typedef typename Pair::first_type const &type;
79 template<typename Pair>
80 typename Pair::first_type &operator()(Pair &pair) const
85 template<typename Pair>
86 typename Pair::first_type const &operator()(Pair const &pair) const
92 /// \brief A PolymorphicFunctionObject type that returns
93 /// the second element of a std::pair.
95 /// A PolymorphicFunctionObject type that returns
96 /// the second element of a std::pair..
99 BOOST_PROTO_CALLABLE()
101 template<typename Sig>
104 template<typename This, typename Pair>
105 struct result<This(Pair)>
107 typedef typename Pair::second_type type;
110 template<typename This, typename Pair>
111 struct result<This(Pair &)>
113 typedef typename Pair::second_type &type;
116 template<typename This, typename Pair>
117 struct result<This(Pair const &)>
119 typedef typename Pair::second_type const &type;
122 template<typename Pair>
123 typename Pair::second_type &operator()(Pair &pair) const
128 template<typename Pair>
129 typename Pair::second_type const &operator()(Pair const &pair) const