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   bind_to_log.hpp
0009  * \author Andrey Semashev
0010  * \date   06.11.2012
0011  *
0012  * This header contains a function object that puts the received value to the bound stream using the \c to_log manipulator.
0013  * This is a lightweight alternative to what Boost.Phoenix and Boost.Lambda provides.
0014  */
0015 
0016 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_BIND_TO_LOG_HPP_INCLUDED_
0017 #define BOOST_LOG_UTILITY_FUNCTIONAL_BIND_TO_LOG_HPP_INCLUDED_
0018 
0019 #include <boost/log/detail/config.hpp>
0020 #include <boost/log/utility/functional/bind.hpp>
0021 #include <boost/log/utility/manipulators/to_log.hpp>
0022 #include <boost/log/detail/header.hpp>
0023 
0024 #ifdef BOOST_HAS_PRAGMA_ONCE
0025 #pragma once
0026 #endif
0027 
0028 namespace boost {
0029 
0030 BOOST_LOG_OPEN_NAMESPACE
0031 
0032 //! The function object that outputs its second operand to the first one
0033 template< typename TagT = void >
0034 struct to_log_fun
0035 {
0036     typedef void result_type;
0037 
0038     template< typename StreamT, typename T >
0039     void operator() (StreamT& strm, T const& val) const
0040     {
0041         strm << boost::log::to_log< TagT >(val);
0042     }
0043 };
0044 
0045 //! The function object that outputs its second operand to the first one
0046 template< >
0047 struct to_log_fun< void >
0048 {
0049     typedef void result_type;
0050 
0051     template< typename StreamT, typename T >
0052     void operator() (StreamT& strm, T const& val) const
0053     {
0054         strm << boost::log::to_log(val);
0055     }
0056 };
0057 
0058 template< typename StreamT >
0059 BOOST_FORCEINLINE binder1st< to_log_fun< >, StreamT& > bind_to_log(StreamT& strm)
0060 {
0061     return binder1st< to_log_fun< >, StreamT& >(to_log_fun< >(), strm);
0062 }
0063 
0064 template< typename TagT, typename StreamT >
0065 BOOST_FORCEINLINE binder1st< to_log_fun< TagT >, StreamT& > bind_to_log(StreamT& strm)
0066 {
0067     return binder1st< to_log_fun< TagT >, StreamT& >(to_log_fun< TagT >(), strm);
0068 }
0069 
0070 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0071 
0072 } // namespace boost
0073 
0074 #include <boost/log/detail/footer.hpp>
0075 
0076 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_BIND_TO_LOG_HPP_INCLUDED_