File indexing completed on 2025-01-18 09:39:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_LOG_ATTRIBUTES_ATTRIBUTE_VALUE_IMPL_HPP_INCLUDED_
0016 #define BOOST_LOG_ATTRIBUTES_ATTRIBUTE_VALUE_IMPL_HPP_INCLUDED_
0017
0018 #include <boost/type_index.hpp>
0019 #include <boost/move/core.hpp>
0020 #include <boost/move/utility_core.hpp>
0021 #include <boost/type_traits/remove_cv.hpp>
0022 #include <boost/type_traits/is_nothrow_move_constructible.hpp>
0023 #include <boost/log/detail/config.hpp>
0024 #include <boost/log/attributes/attribute_value.hpp>
0025 #include <boost/log/utility/type_dispatch/type_dispatcher.hpp>
0026 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0027 #include <boost/type_traits/remove_reference.hpp>
0028 #endif
0029 #include <boost/log/detail/header.hpp>
0030
0031 #ifdef BOOST_HAS_PRAGMA_ONCE
0032 #pragma once
0033 #endif
0034
0035 namespace boost {
0036
0037 BOOST_LOG_OPEN_NAMESPACE
0038
0039 namespace attributes {
0040
0041
0042
0043
0044
0045
0046
0047
0048 template< typename T >
0049 class attribute_value_impl :
0050 public attribute_value::impl
0051 {
0052 public:
0053
0054 typedef T value_type;
0055
0056 private:
0057
0058 const value_type m_value;
0059
0060 public:
0061
0062
0063
0064 explicit attribute_value_impl(value_type const& v) : m_value(v) {}
0065
0066
0067
0068 explicit attribute_value_impl(BOOST_RV_REF(value_type) v) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible< value_type >::value) :
0069 m_value(boost::move(v))
0070 {
0071 }
0072
0073
0074
0075
0076
0077
0078
0079
0080 bool dispatch(type_dispatcher& dispatcher) BOOST_OVERRIDE
0081 {
0082 type_dispatcher::callback< value_type > callback = dispatcher.get_callback< value_type >();
0083 if (callback)
0084 {
0085 callback(m_value);
0086 return true;
0087 }
0088 else
0089 return false;
0090 }
0091
0092
0093
0094
0095 typeindex::type_index get_type() const BOOST_OVERRIDE { return typeindex::type_id< value_type >(); }
0096
0097
0098
0099
0100 value_type const& get() const { return m_value; }
0101 };
0102
0103
0104
0105
0106 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0107
0108 template< typename T >
0109 inline attribute_value make_attribute_value(T&& v)
0110 {
0111 typedef typename remove_cv< typename remove_reference< T >::type >::type value_type;
0112 return attribute_value(new attribute_value_impl< value_type >(boost::forward< T >(v)));
0113 }
0114
0115 #else
0116
0117 template< typename T >
0118 inline attribute_value make_attribute_value(T const& v)
0119 {
0120 typedef typename remove_cv< T >::type value_type;
0121 return attribute_value(new attribute_value_impl< value_type >(v));
0122 }
0123
0124 template< typename T >
0125 inline attribute_value make_attribute_value(rv< T > const& v)
0126 {
0127 typedef typename remove_cv< T >::type value_type;
0128 return attribute_value(new attribute_value_impl< value_type >(v));
0129 }
0130
0131 #endif
0132
0133 }
0134
0135 BOOST_LOG_CLOSE_NAMESPACE
0136
0137 }
0138
0139 #include <boost/log/detail/footer.hpp>
0140
0141 #endif