annotate DEPENDENCIES/generic/include/boost/log/utility/functional/fun_ref.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /*
Chris@101 2 * Copyright Andrey Semashev 2007 - 2015.
Chris@16 3 * Distributed under the Boost Software License, Version 1.0.
Chris@16 4 * (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7 /*!
Chris@16 8 * \file fun_ref.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 30.03.2008
Chris@16 11 *
Chris@16 12 * This header contains function object reference adapter. The adapter stores a reference to external
Chris@16 13 * function object and forwards all calls to the referred function.
Chris@16 14 */
Chris@16 15
Chris@16 16 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_
Chris@16 17 #define BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_
Chris@16 18
Chris@16 19 #include <boost/log/detail/config.hpp>
Chris@16 20 #include <boost/log/detail/header.hpp>
Chris@16 21
Chris@16 22 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 23 #pragma once
Chris@16 24 #endif
Chris@16 25
Chris@16 26 namespace boost {
Chris@16 27
Chris@16 28 BOOST_LOG_OPEN_NAMESPACE
Chris@16 29
Chris@16 30 //! Reference wrapper for function objects
Chris@16 31 template< typename FunT >
Chris@16 32 struct function_reference_wrapper
Chris@16 33 {
Chris@16 34 typedef typename FunT::result_type result_type;
Chris@16 35
Chris@16 36 explicit function_reference_wrapper(FunT& fun) : m_Fun(fun) {}
Chris@16 37
Chris@16 38 result_type operator() () const
Chris@16 39 {
Chris@16 40 return m_Fun();
Chris@16 41 }
Chris@16 42
Chris@16 43 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@16 44 template< typename... ArgsT >
Chris@16 45 result_type operator() (ArgsT const&... args) const
Chris@16 46 {
Chris@16 47 return m_Fun(args...);
Chris@16 48 }
Chris@16 49 #else
Chris@16 50 template< typename T >
Chris@16 51 result_type operator() (T const& arg) const
Chris@16 52 {
Chris@16 53 return m_Fun(arg);
Chris@16 54 }
Chris@16 55
Chris@16 56 template< typename T1, typename T2 >
Chris@16 57 result_type operator() (T1 const& arg1, T2 const& arg2) const
Chris@16 58 {
Chris@16 59 return m_Fun(arg1, arg2);
Chris@16 60 }
Chris@16 61 #endif
Chris@16 62
Chris@16 63 private:
Chris@16 64 FunT& m_Fun;
Chris@16 65 };
Chris@16 66
Chris@16 67 template< typename FunT >
Chris@16 68 BOOST_FORCEINLINE function_reference_wrapper< FunT > fun_ref(FunT& fun)
Chris@16 69 {
Chris@16 70 return function_reference_wrapper< FunT >(fun);
Chris@16 71 }
Chris@16 72
Chris@16 73 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 74
Chris@16 75 } // namespace boost
Chris@16 76
Chris@16 77 #include <boost/log/detail/footer.hpp>
Chris@16 78
Chris@16 79 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_