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)
9 * \author Andrey Semashev
12 * This header contains function object reference adapter. The adapter stores a reference to external
13 * function object and forwards all calls to the referred function.
16 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_
17 #define BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_
19 #include <boost/log/detail/config.hpp>
20 #include <boost/log/detail/header.hpp>
22 #ifdef BOOST_HAS_PRAGMA_ONCE
28 BOOST_LOG_OPEN_NAMESPACE
30 //! Reference wrapper for function objects
31 template< typename FunT >
32 struct function_reference_wrapper
34 typedef typename FunT::result_type result_type;
36 explicit function_reference_wrapper(FunT& fun) : m_Fun(fun) {}
38 result_type operator() () const
43 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
44 template< typename... ArgsT >
45 result_type operator() (ArgsT const&... args) const
47 return m_Fun(args...);
50 template< typename T >
51 result_type operator() (T const& arg) const
56 template< typename T1, typename T2 >
57 result_type operator() (T1 const& arg1, T2 const& arg2) const
59 return m_Fun(arg1, arg2);
67 template< typename FunT >
68 BOOST_FORCEINLINE function_reference_wrapper< FunT > fun_ref(FunT& fun)
70 return function_reference_wrapper< FunT >(fun);
73 BOOST_LOG_CLOSE_NAMESPACE // namespace log
77 #include <boost/log/detail/footer.hpp>
79 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_