File indexing completed on 2025-01-18 09:39:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_LOG_UTILITY_MANIPULATORS_INVOKE_HPP_INCLUDED_
0016 #define BOOST_LOG_UTILITY_MANIPULATORS_INVOKE_HPP_INCLUDED_
0017
0018 #include <cstddef>
0019 #include <boost/core/enable_if.hpp>
0020 #include <boost/log/detail/config.hpp>
0021 #include <boost/type_traits/remove_cv.hpp>
0022 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0023 #include <boost/type_traits/remove_reference.hpp>
0024 #endif
0025 #include <boost/log/detail/is_ostream.hpp>
0026 #include <boost/log/detail/header.hpp>
0027
0028 #ifdef BOOST_HAS_PRAGMA_ONCE
0029 #pragma once
0030 #endif
0031
0032 namespace boost {
0033
0034 BOOST_LOG_OPEN_NAMESPACE
0035
0036
0037
0038
0039 template< typename FunctionT >
0040 class invoke_manipulator
0041 {
0042 private:
0043 mutable FunctionT m_function;
0044
0045 public:
0046
0047 explicit invoke_manipulator(FunctionT const& func) :
0048 m_function(func)
0049 {
0050 }
0051
0052 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0053
0054 explicit invoke_manipulator(FunctionT&& func) :
0055 m_function(static_cast< FunctionT&& >(func))
0056 {
0057 }
0058 #endif
0059
0060
0061 template< typename StreamT >
0062 void output(StreamT& stream) const
0063 {
0064 m_function(stream);
0065 }
0066 };
0067
0068
0069
0070
0071 template< typename StreamT, typename FunctionT >
0072 inline typename boost::enable_if_c< log::aux::is_ostream< StreamT >::value, StreamT& >::type operator<< (StreamT& stream, invoke_manipulator< FunctionT > const& manip)
0073 {
0074 manip.output(stream);
0075 return stream;
0076 }
0077
0078 #if !defined(BOOST_LOG_DOXYGEN_PASS)
0079
0080 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0081
0082
0083 template< typename FunctionT >
0084 inline invoke_manipulator<
0085 typename boost::remove_cv<
0086 typename boost::remove_reference< FunctionT >::type
0087 >::type
0088 >
0089 invoke_manip(FunctionT&& func)
0090 {
0091 return invoke_manipulator<
0092 typename boost::remove_cv<
0093 typename boost::remove_reference< FunctionT >::type
0094 >::type
0095 >(static_cast< FunctionT&& >(func));
0096 }
0097
0098 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
0099 !defined(BOOST_NO_CXX14_GENERIC_LAMBDAS) && \
0100 !defined(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION)
0101
0102
0103 template< typename FunctionT, typename Arg0, typename... Args >
0104 inline auto invoke_manip(FunctionT&& func, Arg0&& arg0, Args&&... args)
0105 {
0106 return boost::log::invoke_manip
0107 (
0108 #if !defined(BOOST_LOG_NO_CXX20_PACK_EXPANSION_IN_LAMBDA_INIT_CAPTURE)
0109 [func = static_cast< FunctionT&& >(func), arg0 = static_cast< Arg0&& >(arg0), ...args = static_cast< Args&& >(args)](auto& stream) mutable
0110 #else
0111 [func, arg0, args...](auto& stream) mutable
0112 #endif
0113 {
0114 #if !defined(BOOST_MSVC) || BOOST_MSVC >= 1910
0115 static_cast< FunctionT&& >(func)(stream, static_cast< Arg0&& >(arg0), static_cast< Args&& >(args)...);
0116 #else
0117
0118 func(stream, arg0, args...);
0119 #endif
0120 }
0121 );
0122 }
0123
0124 #endif
0125
0126 #else
0127
0128
0129 template< typename FunctionT >
0130 inline invoke_manipulator< typename boost::remove_cv< FunctionT >::type >
0131 invoke_manip(FunctionT const& func)
0132 {
0133 return invoke_manipulator< typename boost::remove_cv< FunctionT >::type >(func);
0134 }
0135
0136 #endif
0137
0138 #else
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149 template< typename FunctionT, typename... Args >
0150 invoke_manipulator< unspecified > invoke_manip(FunctionT&& func, Args&&... args);
0151
0152 #endif
0153
0154 BOOST_LOG_CLOSE_NAMESPACE
0155
0156 }
0157
0158 #include <boost/log/detail/footer.hpp>
0159
0160 #endif