annotate DEPENDENCIES/generic/include/boost/log/detail/unary_function_terminal.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 unary_function_terminal.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 21.07.2012
Chris@16 11 *
Chris@16 12 * The header contains attribute value extractor adapter for constructing expression template terminals.
Chris@16 13 */
Chris@16 14
Chris@16 15 #ifndef BOOST_LOG_DETAIL_UNARY_FUNCTION_TERMINAL_HPP_INCLUDED_
Chris@16 16 #define BOOST_LOG_DETAIL_UNARY_FUNCTION_TERMINAL_HPP_INCLUDED_
Chris@16 17
Chris@16 18 #include <boost/mpl/bool.hpp>
Chris@16 19 #include <boost/utility/result_of.hpp>
Chris@16 20 #include <boost/fusion/sequence/intrinsic/at_c.hpp>
Chris@16 21 #include <boost/phoenix/core/is_nullary.hpp>
Chris@16 22 #include <boost/phoenix/core/environment.hpp>
Chris@16 23 #include <boost/type_traits/remove_cv.hpp>
Chris@16 24 #include <boost/type_traits/remove_reference.hpp>
Chris@16 25 #include <boost/log/detail/config.hpp>
Chris@101 26 #include <boost/log/detail/copy_cv.hpp>
Chris@16 27 #include <boost/log/detail/custom_terminal_spec.hpp>
Chris@16 28 #include <boost/log/detail/header.hpp>
Chris@16 29
Chris@16 30 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 31 #pragma once
Chris@16 32 #endif
Chris@16 33
Chris@16 34 namespace boost {
Chris@16 35
Chris@16 36 BOOST_LOG_OPEN_NAMESPACE
Chris@16 37
Chris@16 38 namespace expressions {
Chris@16 39
Chris@16 40 namespace aux {
Chris@16 41
Chris@16 42 /*!
Chris@16 43 * \brief An adapter for a unary function to be used as a terminal in a Boost.Phoenix expression
Chris@16 44 *
Chris@16 45 * This class is an adapter between Boost.Phoenix expression invocation protocol and
Chris@16 46 * a unary function. It forwards the call to the base function, passing only the first argument
Chris@16 47 * from the original call. This allows to embed value extractors in template expressions.
Chris@16 48 */
Chris@16 49 template< typename FunT >
Chris@16 50 class unary_function_terminal
Chris@16 51 {
Chris@16 52 private:
Chris@16 53 //! Adopted function type
Chris@16 54 typedef FunT function_type;
Chris@16 55 //! Self type
Chris@16 56 typedef unary_function_terminal< function_type > this_type;
Chris@16 57
Chris@16 58 public:
Chris@16 59 //! Internal typedef for type categorization
Chris@16 60 typedef void _is_boost_log_terminal;
Chris@16 61
Chris@16 62 //! Function result type
Chris@16 63 template< typename >
Chris@16 64 struct result;
Chris@16 65
Chris@101 66 template< typename ThisT, typename ContextT >
Chris@101 67 struct result< ThisT(ContextT) >
Chris@16 68 {
Chris@16 69 typedef typename remove_cv<
Chris@16 70 typename remove_reference< typename phoenix::result_of::env< ContextT >::type >::type
Chris@16 71 >::type env_type;
Chris@16 72 typedef typename env_type::args_type args_type;
Chris@101 73 typedef typename boost::log::aux::copy_cv< ThisT, function_type >::type cv_function_type;
Chris@16 74
Chris@101 75 typedef typename boost::result_of< cv_function_type(typename fusion::result_of::at_c< args_type, 0 >::type) >::type type;
Chris@16 76 };
Chris@16 77
Chris@16 78 private:
Chris@16 79 //! Adopted function
Chris@16 80 function_type m_fun;
Chris@16 81
Chris@16 82 public:
Chris@16 83 //! Default constructor
Chris@16 84 BOOST_DEFAULTED_FUNCTION(unary_function_terminal(), {})
Chris@16 85 //! Copy constructor
Chris@16 86 unary_function_terminal(unary_function_terminal const& that) : m_fun(that.m_fun) {}
Chris@16 87 //! Initializing constructor
Chris@16 88 template< typename ArgT1 >
Chris@16 89 explicit unary_function_terminal(ArgT1 const& arg1) : m_fun(arg1) {}
Chris@16 90 //! Initializing constructor
Chris@16 91 template< typename ArgT1, typename ArgT2 >
Chris@16 92 unary_function_terminal(ArgT1 const& arg1, ArgT2 const& arg2) : m_fun(arg1, arg2) {}
Chris@16 93 //! Initializing constructor
Chris@16 94 template< typename ArgT1, typename ArgT2, typename ArgT3 >
Chris@16 95 unary_function_terminal(ArgT1 const& arg1, ArgT2 const& arg2, ArgT3 const& arg3) : m_fun(arg1, arg2, arg3) {}
Chris@16 96
Chris@16 97 //! The operator forwards the call to the base function
Chris@16 98 template< typename ContextT >
Chris@16 99 typename result< this_type(ContextT const&) >::type
Chris@16 100 operator() (ContextT const& ctx)
Chris@16 101 {
Chris@16 102 return m_fun(fusion::at_c< 0 >(phoenix::env(ctx).args()));
Chris@16 103 }
Chris@16 104
Chris@16 105 //! The operator forwards the call to the base function
Chris@16 106 template< typename ContextT >
Chris@16 107 typename result< const this_type(ContextT const&) >::type
Chris@16 108 operator() (ContextT const& ctx) const
Chris@16 109 {
Chris@16 110 return m_fun(fusion::at_c< 0 >(phoenix::env(ctx).args()));
Chris@16 111 }
Chris@16 112 };
Chris@16 113
Chris@16 114 } // namespace aux
Chris@16 115
Chris@16 116 } // namespace expressions
Chris@16 117
Chris@16 118 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 119
Chris@16 120 #ifndef BOOST_LOG_DOXYGEN_PASS
Chris@16 121
Chris@16 122 namespace phoenix {
Chris@16 123
Chris@16 124 namespace result_of {
Chris@16 125
Chris@16 126 template< typename FunT >
Chris@16 127 struct is_nullary< custom_terminal< boost::log::expressions::aux::unary_function_terminal< FunT > > > :
Chris@16 128 public mpl::false_
Chris@16 129 {
Chris@16 130 };
Chris@16 131
Chris@16 132 } // namespace result_of
Chris@16 133
Chris@16 134 } // namespace phoenix
Chris@16 135
Chris@16 136 #endif // BOOST_LOG_DOXYGEN_PASS
Chris@16 137
Chris@16 138 } // namespace boost
Chris@16 139
Chris@16 140 #include <boost/log/detail/footer.hpp>
Chris@16 141
Chris@16 142 #endif // BOOST_LOG_DETAIL_UNARY_FUNCTION_TERMINAL_HPP_INCLUDED_