]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/log/include/boost/log/utility/functional/save_result.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / log / include / boost / log / utility / functional / save_result.hpp
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 save_result.hpp
9 * \author Andrey Semashev
10 * \date 19.01.2013
11 *
12 * This header contains function object adapter that saves the result of the adopted function to an external variable.
13 */
14
15 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_SAVE_RESULT_HPP_INCLUDED_
16 #define BOOST_LOG_UTILITY_FUNCTIONAL_SAVE_RESULT_HPP_INCLUDED_
17
18 #include <boost/log/detail/config.hpp>
19 #include <boost/log/detail/header.hpp>
20
21 #ifdef BOOST_HAS_PRAGMA_ONCE
22 #pragma once
23 #endif
24
25 namespace boost {
26
27 BOOST_LOG_OPEN_NAMESPACE
28
29 //! Function object wrapper for saving the adopted function object result
30 template< typename FunT, typename AssigneeT >
31 struct save_result_wrapper
32 {
33 typedef void result_type;
34
35 save_result_wrapper(FunT fun, AssigneeT& assignee) : m_fun(fun), m_assignee(assignee) {}
36
37 template< typename ArgT >
38 result_type operator() (ArgT const& arg) const
39 {
40 m_assignee = m_fun(arg);
41 }
42
43 private:
44 FunT m_fun;
45 AssigneeT& m_assignee;
46 };
47
48 template< typename FunT, typename AssigneeT >
49 BOOST_FORCEINLINE save_result_wrapper< FunT, AssigneeT > save_result(FunT const& fun, AssigneeT& assignee)
50 {
51 return save_result_wrapper< FunT, AssigneeT >(fun, assignee);
52 }
53
54 BOOST_LOG_CLOSE_NAMESPACE // namespace log
55
56 } // namespace boost
57
58 #include <boost/log/detail/footer.hpp>
59
60 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_SAVE_RESULT_HPP_INCLUDED_