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 bind_to_log.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 06.11.2012 Chris@16: * Chris@16: * This header contains a function object that puts the received value to the bound stream using the \c to_log manipulator. Chris@16: * This is a lightweight alternative to what Boost.Phoenix and Boost.Lambda provides. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_BIND_TO_LOG_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_UTILITY_FUNCTIONAL_BIND_TO_LOG_HPP_INCLUDED_ Chris@16: Chris@16: #include Chris@16: #include 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: //! The function object that outputs its second operand to the first one Chris@16: template< typename TagT = void > Chris@16: struct to_log_fun Chris@16: { Chris@16: typedef void result_type; Chris@16: Chris@16: template< typename StreamT, typename T > Chris@16: void operator() (StreamT& strm, T const& val) const Chris@16: { Chris@16: strm << boost::log::to_log< TagT >(val); Chris@16: } Chris@16: }; Chris@16: Chris@16: //! The function object that outputs its second operand to the first one Chris@16: template< > Chris@16: struct to_log_fun< void > Chris@16: { Chris@16: typedef void result_type; Chris@16: Chris@16: template< typename StreamT, typename T > Chris@16: void operator() (StreamT& strm, T const& val) const Chris@16: { Chris@16: strm << boost::log::to_log(val); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< typename StreamT > Chris@16: BOOST_FORCEINLINE binder1st< to_log_fun< >, StreamT& > bind_to_log(StreamT& strm) Chris@16: { Chris@16: return binder1st< to_log_fun< >, StreamT& >(to_log_fun< >(), strm); Chris@16: } Chris@16: Chris@16: template< typename TagT, typename StreamT > Chris@16: BOOST_FORCEINLINE binder1st< to_log_fun< TagT >, StreamT& > bind_to_log(StreamT& strm) Chris@16: { Chris@16: return binder1st< to_log_fun< TagT >, StreamT& >(to_log_fun< TagT >(), strm); 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_BIND_TO_LOG_HPP_INCLUDED_