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)
8 * \file save_result.hpp
9 * \author Andrey Semashev
12 * This header contains function object adapter that saves the result of the adopted function to an external variable.
15 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_SAVE_RESULT_HPP_INCLUDED_
16 #define BOOST_LOG_UTILITY_FUNCTIONAL_SAVE_RESULT_HPP_INCLUDED_
18 #include <boost/log/detail/config.hpp>
19 #include <boost/log/detail/header.hpp>
21 #ifdef BOOST_HAS_PRAGMA_ONCE
27 BOOST_LOG_OPEN_NAMESPACE
29 //! Function object wrapper for saving the adopted function object result
30 template< typename FunT, typename AssigneeT >
31 struct save_result_wrapper
33 typedef void result_type;
35 save_result_wrapper(FunT fun, AssigneeT& assignee) : m_fun(fun), m_assignee(assignee) {}
37 template< typename ArgT >
38 result_type operator() (ArgT const& arg) const
40 m_assignee = m_fun(arg);
45 AssigneeT& m_assignee;
48 template< typename FunT, typename AssigneeT >
49 BOOST_FORCEINLINE save_result_wrapper< FunT, AssigneeT > save_result(FunT const& fun, AssigneeT& assignee)
51 return save_result_wrapper< FunT, AssigneeT >(fun, assignee);
54 BOOST_LOG_CLOSE_NAMESPACE // namespace log
58 #include <boost/log/detail/footer.hpp>
60 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_SAVE_RESULT_HPP_INCLUDED_