Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file fun_ref.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 30.03.2008 Chris@16: * Chris@16: * This header contains function object reference adapter. The adapter stores a reference to external Chris@16: * function object and forwards all calls to the referred function. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_ Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: //! Reference wrapper for function objects Chris@16: template< typename FunT > Chris@16: struct function_reference_wrapper Chris@16: { Chris@16: typedef typename FunT::result_type result_type; Chris@16: Chris@16: explicit function_reference_wrapper(FunT& fun) : m_Fun(fun) {} Chris@16: Chris@16: result_type operator() () const Chris@16: { Chris@16: return m_Fun(); Chris@16: } Chris@16: Chris@16: #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) Chris@16: template< typename... ArgsT > Chris@16: result_type operator() (ArgsT const&... args) const Chris@16: { Chris@16: return m_Fun(args...); Chris@16: } Chris@16: #else Chris@16: template< typename T > Chris@16: result_type operator() (T const& arg) const Chris@16: { Chris@16: return m_Fun(arg); Chris@16: } Chris@16: Chris@16: template< typename T1, typename T2 > Chris@16: result_type operator() (T1 const& arg1, T2 const& arg2) const Chris@16: { Chris@16: return m_Fun(arg1, arg2); Chris@16: } Chris@16: #endif Chris@16: Chris@16: private: Chris@16: FunT& m_Fun; Chris@16: }; Chris@16: Chris@16: template< typename FunT > Chris@16: BOOST_FORCEINLINE function_reference_wrapper< FunT > fun_ref(FunT& fun) Chris@16: { Chris@16: return function_reference_wrapper< FunT >(fun); Chris@16: } Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_