annotate DEPENDENCIES/generic/include/boost/proto/functional/std/utility.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 ///////////////////////////////////////////////////////////////////////////////
Chris@16 2 /// \file utility.hpp
Chris@16 3 /// Proto callables for things found in the std \<utility\> header
Chris@16 4 //
Chris@16 5 // Copyright 2010 Eric Niebler. Distributed under the Boost
Chris@16 6 // Software License, Version 1.0. (See accompanying file
Chris@16 7 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8
Chris@16 9 #ifndef BOOST_PROTO_FUNCTIONAL_STD_UTILITY_HPP_EAN_11_27_2010
Chris@16 10 #define BOOST_PROTO_FUNCTIONAL_STD_UTILITY_HPP_EAN_11_27_2010
Chris@16 11
Chris@16 12 #include <utility>
Chris@16 13 #include <boost/type_traits/remove_const.hpp>
Chris@16 14 #include <boost/type_traits/remove_reference.hpp>
Chris@16 15 #include <boost/proto/proto_fwd.hpp>
Chris@16 16
Chris@16 17 namespace boost { namespace proto { namespace functional
Chris@16 18 {
Chris@16 19 /// \brief A PolymorphicFunctionObject type that invokes the
Chris@16 20 /// \c std::make_pair() algorithm on its arguments.
Chris@16 21 ///
Chris@16 22 /// A PolymorphicFunctionObject type that invokes the
Chris@16 23 /// \c std::make_pair() algorithm on its arguments.
Chris@16 24 struct make_pair
Chris@16 25 {
Chris@16 26 BOOST_PROTO_CALLABLE()
Chris@16 27
Chris@16 28 template<typename Sig>
Chris@16 29 struct result;
Chris@16 30
Chris@16 31 template<typename This, typename First, typename Second>
Chris@16 32 struct result<This(First, Second)>
Chris@16 33 {
Chris@16 34 typedef
Chris@16 35 std::pair<
Chris@16 36 typename remove_const<typename remove_reference<First>::type>::type
Chris@16 37 , typename remove_const<typename remove_reference<Second>::type>::type
Chris@16 38 >
Chris@16 39 type;
Chris@16 40 };
Chris@16 41
Chris@16 42 template<typename First, typename Second>
Chris@16 43 std::pair<First, Second> operator()(First const &first, Second const &second) const
Chris@16 44 {
Chris@16 45 return std::make_pair(first, second);
Chris@16 46 }
Chris@16 47 };
Chris@16 48
Chris@16 49 /// \brief A PolymorphicFunctionObject type that returns
Chris@16 50 /// the first element of a std::pair.
Chris@16 51 ///
Chris@16 52 /// A PolymorphicFunctionObject type that returns
Chris@16 53 /// the first element of a std::pair..
Chris@16 54 struct first
Chris@16 55 {
Chris@16 56 BOOST_PROTO_CALLABLE()
Chris@16 57
Chris@16 58 template<typename Sig>
Chris@16 59 struct result;
Chris@16 60
Chris@16 61 template<typename This, typename Pair>
Chris@16 62 struct result<This(Pair)>
Chris@16 63 {
Chris@16 64 typedef typename Pair::first_type type;
Chris@16 65 };
Chris@16 66
Chris@16 67 template<typename This, typename Pair>
Chris@16 68 struct result<This(Pair &)>
Chris@16 69 {
Chris@16 70 typedef typename Pair::first_type &type;
Chris@16 71 };
Chris@16 72
Chris@16 73 template<typename This, typename Pair>
Chris@16 74 struct result<This(Pair const &)>
Chris@16 75 {
Chris@16 76 typedef typename Pair::first_type const &type;
Chris@16 77 };
Chris@16 78
Chris@16 79 template<typename Pair>
Chris@16 80 typename Pair::first_type &operator()(Pair &pair) const
Chris@16 81 {
Chris@16 82 return pair.first;
Chris@16 83 }
Chris@16 84
Chris@16 85 template<typename Pair>
Chris@16 86 typename Pair::first_type const &operator()(Pair const &pair) const
Chris@16 87 {
Chris@16 88 return pair.first;
Chris@16 89 }
Chris@16 90 };
Chris@16 91
Chris@16 92 /// \brief A PolymorphicFunctionObject type that returns
Chris@16 93 /// the second element of a std::pair.
Chris@16 94 ///
Chris@16 95 /// A PolymorphicFunctionObject type that returns
Chris@16 96 /// the second element of a std::pair..
Chris@16 97 struct second
Chris@16 98 {
Chris@16 99 BOOST_PROTO_CALLABLE()
Chris@16 100
Chris@16 101 template<typename Sig>
Chris@16 102 struct result;
Chris@16 103
Chris@16 104 template<typename This, typename Pair>
Chris@16 105 struct result<This(Pair)>
Chris@16 106 {
Chris@16 107 typedef typename Pair::second_type type;
Chris@16 108 };
Chris@16 109
Chris@16 110 template<typename This, typename Pair>
Chris@16 111 struct result<This(Pair &)>
Chris@16 112 {
Chris@16 113 typedef typename Pair::second_type &type;
Chris@16 114 };
Chris@16 115
Chris@16 116 template<typename This, typename Pair>
Chris@16 117 struct result<This(Pair const &)>
Chris@16 118 {
Chris@16 119 typedef typename Pair::second_type const &type;
Chris@16 120 };
Chris@16 121
Chris@16 122 template<typename Pair>
Chris@16 123 typename Pair::second_type &operator()(Pair &pair) const
Chris@16 124 {
Chris@16 125 return pair.second;
Chris@16 126 }
Chris@16 127
Chris@16 128 template<typename Pair>
Chris@16 129 typename Pair::second_type const &operator()(Pair const &pair) const
Chris@16 130 {
Chris@16 131 return pair.second;
Chris@16 132 }
Chris@16 133 };
Chris@16 134
Chris@16 135 }}}
Chris@16 136
Chris@16 137 #endif