]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/log/include/boost/log/utility/functional/fun_ref.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / log / include / boost / log / utility / functional / fun_ref.hpp
CommitLineData
7c673cae
FG
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 fun_ref.hpp
9 * \author Andrey Semashev
10 * \date 30.03.2008
11 *
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.
14 */
15
16#ifndef BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_
17#define BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_
18
19#include <boost/log/detail/config.hpp>
20#include <boost/log/detail/header.hpp>
21
22#ifdef BOOST_HAS_PRAGMA_ONCE
23#pragma once
24#endif
25
26namespace boost {
27
28BOOST_LOG_OPEN_NAMESPACE
29
30//! Reference wrapper for function objects
31template< typename FunT >
32struct function_reference_wrapper
33{
34 typedef typename FunT::result_type result_type;
35
36 explicit function_reference_wrapper(FunT& fun) : m_Fun(fun) {}
37
38 result_type operator() () const
39 {
40 return m_Fun();
41 }
42
43#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
44 template< typename... ArgsT >
45 result_type operator() (ArgsT const&... args) const
46 {
47 return m_Fun(args...);
48 }
49#else
50 template< typename T >
51 result_type operator() (T const& arg) const
52 {
53 return m_Fun(arg);
54 }
55
56 template< typename T1, typename T2 >
57 result_type operator() (T1 const& arg1, T2 const& arg2) const
58 {
59 return m_Fun(arg1, arg2);
60 }
61#endif
62
63private:
64 FunT& m_Fun;
65};
66
67template< typename FunT >
68BOOST_FORCEINLINE function_reference_wrapper< FunT > fun_ref(FunT& fun)
69{
70 return function_reference_wrapper< FunT >(fun);
71}
72
73BOOST_LOG_CLOSE_NAMESPACE // namespace log
74
75} // namespace boost
76
77#include <boost/log/detail/footer.hpp>
78
79#endif // BOOST_LOG_UTILITY_FUNCTIONAL_FUN_REF_HPP_INCLUDED_