| 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 bind_output.hpp |
| 9 | * \author Andrey Semashev |
| 10 | * \date 30.03.2008 |
| 11 | * |
| 12 | * This header contains a function object that puts the received value to the bound stream. |
| 13 | * This is a lightweight alternative to what Boost.Phoenix and Boost.Lambda provides. |
| 14 | */ |
| 15 | |
| 16 | #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_BIND_OUTPUT_HPP_INCLUDED_ |
| 17 | #define BOOST_LOG_UTILITY_FUNCTIONAL_BIND_OUTPUT_HPP_INCLUDED_ |
| 18 | |
| 19 | #include <boost/log/detail/config.hpp> |
| 20 | #include <boost/log/utility/functional/bind.hpp> |
| 21 | #include <boost/log/detail/header.hpp> |
| 22 | |
| 23 | #ifdef BOOST_HAS_PRAGMA_ONCE |
| 24 | #pragma once |
| 25 | #endif |
| 26 | |
| 27 | namespace boost { |
| 28 | |
| 29 | BOOST_LOG_OPEN_NAMESPACE |
| 30 | |
| 31 | //! The function object that outputs its second operand to the first one |
| 32 | struct output_fun |
| 33 | { |
| 34 | typedef void result_type; |
| 35 | |
| 36 | template< typename StreamT, typename T > |
| 37 | void operator() (StreamT& strm, T const& val) const |
| 38 | { |
| 39 | strm << val; |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | template< typename StreamT > |
| 44 | BOOST_FORCEINLINE binder1st< output_fun, StreamT& > bind_output(StreamT& strm) |
| 45 | { |
| 46 | return binder1st< output_fun, StreamT& >(output_fun(), strm); |
| 47 | } |
| 48 | |
| 49 | BOOST_LOG_CLOSE_NAMESPACE // namespace log |
| 50 | |
| 51 | } // namespace boost |
| 52 | |
| 53 | #include <boost/log/detail/footer.hpp> |
| 54 | |
| 55 | #endif // BOOST_LOG_UTILITY_FUNCTIONAL_BIND_OUTPUT_HPP_INCLUDED_ |
| 56 |
