Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file as_action.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 30.03.2008 Chris@16: * Chris@16: * This header contains function object adapter for compatibility with Boost.Spirit actions interface requirements. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_AS_ACTION_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_UTILITY_FUNCTIONAL_AS_ACTION_HPP_INCLUDED_ Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: //! Function object adapter for Boost.Spirit actions Chris@16: template< typename FunT > Chris@16: struct as_action_adapter Chris@16: { Chris@16: typedef typename FunT::result_type result_type; Chris@16: Chris@16: BOOST_DEFAULTED_FUNCTION(as_action_adapter(), {}) Chris@16: explicit as_action_adapter(FunT const& fun) : m_fun(fun) {} Chris@16: Chris@16: template< typename AttributeT, typename ContextT > Chris@16: result_type operator() (AttributeT const& attr, ContextT const& ctx, bool& pass) const Chris@16: { Chris@16: return m_fun(attr); Chris@16: } Chris@16: Chris@16: private: Chris@16: FunT m_fun; Chris@16: }; Chris@16: Chris@16: template< typename FunT > Chris@16: BOOST_FORCEINLINE as_action_adapter< FunT > as_action(FunT const& fun) Chris@16: { Chris@16: return as_action_adapter< FunT >(fun); Chris@16: } Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_UTILITY_FUNCTIONAL_AS_ACTION_HPP_INCLUDED_