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   save_result.hpp
0009  * \author Andrey Semashev
0010  * \date   19.01.2013
0011  *
0012  * This header contains function object adapter that saves the result of the adopted function to an external variable.
0013  */
0014 
0015 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_SAVE_RESULT_HPP_INCLUDED_
0016 #define BOOST_LOG_UTILITY_FUNCTIONAL_SAVE_RESULT_HPP_INCLUDED_
0017 
0018 #include <boost/log/detail/config.hpp>
0019 #include <boost/log/detail/header.hpp>
0020 
0021 #ifdef BOOST_HAS_PRAGMA_ONCE
0022 #pragma once
0023 #endif
0024 
0025 namespace boost {
0026 
0027 BOOST_LOG_OPEN_NAMESPACE
0028 
0029 //! Function object wrapper for saving the adopted function object result
0030 template< typename FunT, typename AssigneeT >
0031 struct save_result_wrapper
0032 {
0033     typedef void result_type;
0034 
0035     save_result_wrapper(FunT fun, AssigneeT& assignee) : m_fun(fun), m_assignee(assignee) {}
0036 
0037     template< typename ArgT >
0038     result_type operator() (ArgT const& arg) const
0039     {
0040         m_assignee = m_fun(arg);
0041     }
0042 
0043 private:
0044     FunT m_fun;
0045     AssigneeT& m_assignee;
0046 };
0047 
0048 template< typename FunT, typename AssigneeT >
0049 BOOST_FORCEINLINE save_result_wrapper< FunT, AssigneeT > save_result(FunT const& fun, AssigneeT& assignee)
0050 {
0051     return save_result_wrapper< FunT, AssigneeT >(fun, assignee);
0052 }
0053 
0054 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0055 
0056 } // namespace boost
0057 
0058 #include <boost/log/detail/footer.hpp>
0059 
0060 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_SAVE_RESULT_HPP_INCLUDED_