custom_terminal_spec.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #ifndef BOOST_LOG_DETAIL_CUSTOM_TERMINAL_SPEC_HPP_INCLUDED_
  15. #define BOOST_LOG_DETAIL_CUSTOM_TERMINAL_SPEC_HPP_INCLUDED_
  16. #include <boost/mpl/bool.hpp>
  17. #include <boost/phoenix/core/terminal_fwd.hpp>
  18. #include <boost/phoenix/core/is_nullary.hpp>
  19. #include <boost/phoenix/core/terminal.hpp> // needed for terminal-related part of the grammar
  20. #include <boost/type_traits/remove_cv.hpp>
  21. #include <boost/type_traits/remove_reference.hpp>
  22. #include <boost/utility/result_of.hpp>
  23. #include <boost/log/detail/config.hpp>
  24. #include <boost/log/detail/header.hpp>
  25. #ifdef BOOST_HAS_PRAGMA_ONCE
  26. #pragma once
  27. #endif
  28. namespace boost {
  29. namespace phoenix {
  30. template< typename T >
  31. struct is_custom_terminal< T, typename T::_is_boost_log_terminal > :
  32. public mpl::true_
  33. {
  34. };
  35. template< typename T >
  36. struct custom_terminal< T, typename T::_is_boost_log_terminal >
  37. {
  38. typedef custom_terminal< T, typename T::_is_boost_log_terminal > this_type;
  39. template< typename >
  40. struct result;
  41. template< typename ThisT, typename TermT, typename ContextT >
  42. struct result< ThisT(TermT, ContextT) >
  43. {
  44. typedef typename remove_cv< typename remove_reference< TermT >::type >::type term;
  45. typedef typename boost::result_of< const term(ContextT) >::type type;
  46. };
  47. template< typename ContextT >
  48. typename result< const this_type(T const&, ContextT&) >::type operator() (T const& term, ContextT& ctx) const
  49. {
  50. return term(ctx);
  51. }
  52. };
  53. } // namespace phoenix
  54. } // namespace boost
  55. #include <boost/log/detail/footer.hpp>
  56. #endif // BOOST_LOG_DETAIL_CUSTOM_TERMINAL_SPEC_HPP_INCLUDED_