Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:27

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   as_action.hpp
0009  * \author Andrey Semashev
0010  * \date   30.03.2008
0011  *
0012  * This header contains function object adapter for compatibility with Boost.Spirit actions interface requirements.
0013  */
0014 
0015 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_AS_ACTION_HPP_INCLUDED_
0016 #define BOOST_LOG_UTILITY_FUNCTIONAL_AS_ACTION_HPP_INCLUDED_
0017 
0018 #include <boost/log/detail/config.hpp>
0019 #include <boost/log/detail/header.hpp>
0020 
0021 #ifdef BOOST_HAS_PRAGMA_ONCE
0022 #pragma once
0023 #endif
0024 
0025 namespace boost {
0026 
0027 BOOST_LOG_OPEN_NAMESPACE
0028 
0029 //! Function object adapter for Boost.Spirit actions
0030 template< typename FunT >
0031 struct as_action_adapter
0032 {
0033     typedef typename FunT::result_type result_type;
0034 
0035     BOOST_DEFAULTED_FUNCTION(as_action_adapter(), {})
0036     explicit as_action_adapter(FunT const& fun) : m_fun(fun) {}
0037 
0038     template< typename AttributeT, typename ContextT >
0039     result_type operator() (AttributeT const& attr, ContextT const& ctx, bool& pass) const
0040     {
0041         return m_fun(attr);
0042     }
0043 
0044 private:
0045     FunT m_fun;
0046 };
0047 
0048 template< typename FunT >
0049 BOOST_FORCEINLINE as_action_adapter< FunT > as_action(FunT const& fun)
0050 {
0051     return as_action_adapter< FunT >(fun);
0052 }
0053 
0054 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0055 
0056 } // namespace boost
0057 
0058 #include <boost/log/detail/footer.hpp>
0059 
0060 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_AS_ACTION_HPP_INCLUDED_