1 /* 2 * Copyright Andrey Semashev 2007 - 2015. 3 * Distributed under the Boost Software License, Version 1.0. 4 * (See accompanying file LICENSE_1_0.txt or copy at 5 * http://www.boost.org/LICENSE_1_0.txt) 6 */ 7 /*! 8 * \file custom_terminal_spec.hpp 9 * \author Andrey Semashev 10 * \date 29.01.2012 11 * 12 * The header contains Boost.Phoenix custom terminal specialization for Boost.Log terminals. 13 */ 14 15 #ifndef BOOST_LOG_DETAIL_CUSTOM_TERMINAL_SPEC_HPP_INCLUDED_ 16 #define BOOST_LOG_DETAIL_CUSTOM_TERMINAL_SPEC_HPP_INCLUDED_ 17 18 #include <boost/mpl/bool.hpp> 19 #include <boost/phoenix/core/terminal_fwd.hpp> 20 #include <boost/phoenix/core/is_nullary.hpp> 21 #include <boost/phoenix/core/terminal.hpp> // needed for terminal-related part of the grammar 22 #include <boost/type_traits/remove_cv.hpp> 23 #include <boost/type_traits/remove_reference.hpp> 24 #include <boost/utility/result_of.hpp> 25 #include <boost/log/detail/config.hpp> 26 #include <boost/log/detail/header.hpp> 27 28 #ifdef BOOST_HAS_PRAGMA_ONCE 29 #pragma once 30 #endif 31 32 namespace boost { 33 34 namespace phoenix { 35 36 template< typename T > 37 struct is_custom_terminal< T, typename T::_is_boost_log_terminal > : 38 public mpl::true_ 39 { 40 }; 41 42 template< typename T > 43 struct custom_terminal< T, typename T::_is_boost_log_terminal > 44 { 45 typedef custom_terminal< T, typename T::_is_boost_log_terminal > this_type; 46 47 template< typename > 48 struct result; 49 50 template< typename ThisT, typename TermT, typename ContextT > 51 struct result< ThisT(TermT, ContextT) > 52 { 53 typedef typename remove_cv< typename remove_reference< TermT >::type >::type term; 54 typedef typename boost::result_of< const term(ContextT) >::type type; 55 }; 56 57 template< typename ContextT > operator ()boost::phoenix::custom_terminal58 typename result< const this_type(T const&, ContextT&) >::type operator() (T const& term, ContextT& ctx) const 59 { 60 return term(ctx); 61 } 62 }; 63 64 } // namespace phoenix 65 66 } // namespace boost 67 68 #include <boost/log/detail/footer.hpp> 69 70 #endif // BOOST_LOG_DETAIL_CUSTOM_TERMINAL_SPEC_HPP_INCLUDED_ 71