annotate DEPENDENCIES/generic/include/boost/log/utility/functional/bind.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 c530137014c0
children
rev   line source
Chris@16 1 /*
Chris@101 2 * Copyright Andrey Semashev 2007 - 2015.
Chris@16 3 * Distributed under the Boost Software License, Version 1.0.
Chris@16 4 * (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7 /*!
Chris@16 8 * \file bind.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 30.03.2008
Chris@16 11 *
Chris@16 12 * This header contains function object adapters.
Chris@16 13 * This is a lightweight alternative to what Boost.Phoenix and Boost.Bind provides.
Chris@16 14 */
Chris@16 15
Chris@16 16 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_BIND_HPP_INCLUDED_
Chris@16 17 #define BOOST_LOG_UTILITY_FUNCTIONAL_BIND_HPP_INCLUDED_
Chris@16 18
Chris@16 19 #include <boost/type_traits/remove_cv.hpp>
Chris@16 20 #include <boost/log/detail/config.hpp>
Chris@16 21 #include <boost/log/detail/header.hpp>
Chris@16 22
Chris@16 23 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 24 #pragma once
Chris@16 25 #endif
Chris@16 26
Chris@16 27 namespace boost {
Chris@16 28
Chris@16 29 BOOST_LOG_OPEN_NAMESPACE
Chris@16 30
Chris@16 31 namespace aux {
Chris@16 32
Chris@16 33 template< typename T >
Chris@16 34 struct make_arg_type
Chris@16 35 {
Chris@16 36 typedef T const& type;
Chris@16 37 };
Chris@16 38
Chris@16 39 template< typename T >
Chris@16 40 struct make_arg_type< T& >
Chris@16 41 {
Chris@16 42 typedef T& type;
Chris@16 43 };
Chris@16 44
Chris@16 45 } // namespace aux
Chris@16 46
Chris@16 47 //! First argument binder
Chris@16 48 template< typename FunT, typename FirstArgT >
Chris@16 49 struct binder1st :
Chris@16 50 private FunT
Chris@16 51 {
Chris@16 52 typedef typename FunT::result_type result_type;
Chris@16 53
Chris@16 54 binder1st(FunT const& fun, typename aux::make_arg_type< FirstArgT >::type arg) : FunT(fun), m_arg(arg) {}
Chris@16 55
Chris@16 56 result_type operator() () const
Chris@16 57 {
Chris@16 58 return FunT::operator()(m_arg);
Chris@16 59 }
Chris@16 60
Chris@16 61 template< typename T0 >
Chris@16 62 result_type operator() (T0 const& arg0) const
Chris@16 63 {
Chris@16 64 return FunT::operator()(m_arg, arg0);
Chris@16 65 }
Chris@16 66
Chris@16 67 template< typename T0, typename T1 >
Chris@16 68 result_type operator() (T0 const& arg0, T1 const& arg1) const
Chris@16 69 {
Chris@16 70 return FunT::operator()(m_arg, arg0, arg1);
Chris@16 71 }
Chris@16 72
Chris@16 73 private:
Chris@16 74 FirstArgT m_arg;
Chris@16 75 };
Chris@16 76
Chris@16 77 //! First argument binder
Chris@16 78 template< typename FunT, typename FirstArgT >
Chris@16 79 struct binder1st< FunT&, FirstArgT >
Chris@16 80 {
Chris@16 81 typedef typename remove_cv< FunT >::type::result_type result_type;
Chris@16 82
Chris@16 83 binder1st(FunT& fun, typename aux::make_arg_type< FirstArgT >::type arg) : m_fun(fun), m_arg(arg) {}
Chris@16 84
Chris@16 85 result_type operator() () const
Chris@16 86 {
Chris@16 87 return m_fun(m_arg);
Chris@16 88 }
Chris@16 89
Chris@16 90 template< typename T0 >
Chris@16 91 result_type operator() (T0 const& arg0) const
Chris@16 92 {
Chris@16 93 return m_fun(m_arg, arg0);
Chris@16 94 }
Chris@16 95
Chris@16 96 template< typename T0, typename T1 >
Chris@16 97 result_type operator() (T0 const& arg0, T1 const& arg1) const
Chris@16 98 {
Chris@16 99 return m_fun(m_arg, arg0, arg1);
Chris@16 100 }
Chris@16 101
Chris@16 102 private:
Chris@16 103 FunT& m_fun;
Chris@16 104 FirstArgT m_arg;
Chris@16 105 };
Chris@16 106
Chris@16 107 template< typename FunT, typename FirstArgT >
Chris@16 108 BOOST_FORCEINLINE binder1st< FunT, FirstArgT > bind1st(FunT fun, FirstArgT const& arg)
Chris@16 109 {
Chris@16 110 return binder1st< FunT, FirstArgT >(fun, arg);
Chris@16 111 }
Chris@16 112
Chris@16 113 template< typename FunT, typename FirstArgT >
Chris@16 114 BOOST_FORCEINLINE binder1st< FunT, FirstArgT > bind1st(FunT fun, FirstArgT& arg)
Chris@16 115 {
Chris@16 116 return binder1st< FunT, FirstArgT >(fun, arg);
Chris@16 117 }
Chris@16 118
Chris@16 119 //! Second argument binder
Chris@16 120 template< typename FunT, typename SecondArgT >
Chris@16 121 struct binder2nd :
Chris@16 122 private FunT
Chris@16 123 {
Chris@16 124 typedef typename FunT::result_type result_type;
Chris@16 125
Chris@16 126 binder2nd(FunT const& fun, typename aux::make_arg_type< SecondArgT >::type arg) : FunT(fun), m_arg(arg) {}
Chris@16 127
Chris@16 128 template< typename T >
Chris@16 129 result_type operator() (T const& arg) const
Chris@16 130 {
Chris@16 131 return FunT::operator()(arg, m_arg);
Chris@16 132 }
Chris@16 133
Chris@16 134 template< typename T0, typename T1 >
Chris@16 135 result_type operator() (T0 const& arg0, T1 const& arg1) const
Chris@16 136 {
Chris@16 137 return FunT::operator()(arg0, m_arg, arg1);
Chris@16 138 }
Chris@16 139
Chris@16 140 private:
Chris@16 141 SecondArgT m_arg;
Chris@16 142 };
Chris@16 143
Chris@16 144 //! Second argument binder
Chris@16 145 template< typename FunT, typename SecondArgT >
Chris@16 146 struct binder2nd< FunT&, SecondArgT >
Chris@16 147 {
Chris@16 148 typedef typename remove_cv< FunT >::type::result_type result_type;
Chris@16 149
Chris@16 150 binder2nd(FunT& fun, typename aux::make_arg_type< SecondArgT >::type arg) : m_fun(fun), m_arg(arg) {}
Chris@16 151
Chris@16 152 template< typename T >
Chris@16 153 result_type operator() (T const& arg) const
Chris@16 154 {
Chris@16 155 return m_fun(arg, m_arg);
Chris@16 156 }
Chris@16 157
Chris@16 158 template< typename T0, typename T1 >
Chris@16 159 result_type operator() (T0 const& arg0, T1 const& arg1) const
Chris@16 160 {
Chris@16 161 return m_fun(arg0, m_arg, arg1);
Chris@16 162 }
Chris@16 163
Chris@16 164 private:
Chris@16 165 FunT& m_fun;
Chris@16 166 SecondArgT m_arg;
Chris@16 167 };
Chris@16 168
Chris@16 169 template< typename FunT, typename SecondArgT >
Chris@16 170 BOOST_FORCEINLINE binder2nd< FunT, SecondArgT > bind2nd(FunT fun, SecondArgT const& arg)
Chris@16 171 {
Chris@16 172 return binder2nd< FunT, SecondArgT >(fun, arg);
Chris@16 173 }
Chris@16 174
Chris@16 175 template< typename FunT, typename SecondArgT >
Chris@16 176 BOOST_FORCEINLINE binder2nd< FunT, SecondArgT > bind2nd(FunT fun, SecondArgT& arg)
Chris@16 177 {
Chris@16 178 return binder2nd< FunT, SecondArgT >(fun, arg);
Chris@16 179 }
Chris@16 180
Chris@16 181 //! Third argument binder
Chris@16 182 template< typename FunT, typename ThirdArgT >
Chris@16 183 struct binder3rd :
Chris@16 184 private FunT
Chris@16 185 {
Chris@16 186 typedef typename FunT::result_type result_type;
Chris@16 187
Chris@16 188 binder3rd(FunT const& fun, typename aux::make_arg_type< ThirdArgT >::type arg) : FunT(fun), m_arg(arg) {}
Chris@16 189
Chris@16 190 template< typename T0, typename T1 >
Chris@16 191 result_type operator() (T0 const& arg0, T1 const& arg1) const
Chris@16 192 {
Chris@16 193 return FunT::operator()(arg0, arg1, m_arg);
Chris@16 194 }
Chris@16 195
Chris@16 196 private:
Chris@16 197 ThirdArgT m_arg;
Chris@16 198 };
Chris@16 199
Chris@16 200 //! Third argument binder
Chris@16 201 template< typename FunT, typename ThirdArgT >
Chris@16 202 struct binder3rd< FunT&, ThirdArgT >
Chris@16 203 {
Chris@16 204 typedef typename remove_cv< FunT >::type::result_type result_type;
Chris@16 205
Chris@16 206 binder3rd(FunT& fun, typename aux::make_arg_type< ThirdArgT >::type arg) : m_fun(fun), m_arg(arg) {}
Chris@16 207
Chris@16 208 template< typename T0, typename T1 >
Chris@16 209 result_type operator() (T0 const& arg0, T1 const& arg1) const
Chris@16 210 {
Chris@16 211 return m_fun(arg0, arg1, m_arg);
Chris@16 212 }
Chris@16 213
Chris@16 214 private:
Chris@16 215 FunT& m_fun;
Chris@16 216 ThirdArgT m_arg;
Chris@16 217 };
Chris@16 218
Chris@16 219 template< typename FunT, typename ThirdArgT >
Chris@16 220 BOOST_FORCEINLINE binder3rd< FunT, ThirdArgT > bind3rd(FunT fun, ThirdArgT const& arg)
Chris@16 221 {
Chris@16 222 return binder3rd< FunT, ThirdArgT >(fun, arg);
Chris@16 223 }
Chris@16 224
Chris@16 225 template< typename FunT, typename ThirdArgT >
Chris@16 226 BOOST_FORCEINLINE binder3rd< FunT, ThirdArgT > bind3rd(FunT fun, ThirdArgT& arg)
Chris@16 227 {
Chris@16 228 return binder3rd< FunT, ThirdArgT >(fun, arg);
Chris@16 229 }
Chris@16 230
Chris@16 231 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 232
Chris@16 233 } // namespace boost
Chris@16 234
Chris@16 235 #include <boost/log/detail/footer.hpp>
Chris@16 236
Chris@16 237 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_BIND_HPP_INCLUDED_