123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- #ifndef BOOST_LOG_ATTRIBUTES_ATTRIBUTE_VALUE_IMPL_HPP_INCLUDED_
- #define BOOST_LOG_ATTRIBUTES_ATTRIBUTE_VALUE_IMPL_HPP_INCLUDED_
- #include <boost/type_index.hpp>
- #include <boost/move/core.hpp>
- #include <boost/move/utility_core.hpp>
- #include <boost/type_traits/remove_cv.hpp>
- #include <boost/type_traits/is_nothrow_move_constructible.hpp>
- #include <boost/log/detail/config.hpp>
- #include <boost/log/attributes/attribute_value.hpp>
- #include <boost/log/utility/type_dispatch/type_dispatcher.hpp>
- #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
- #include <boost/type_traits/remove_reference.hpp>
- #endif
- #include <boost/log/detail/header.hpp>
- #ifdef BOOST_HAS_PRAGMA_ONCE
- #pragma once
- #endif
- namespace boost {
- BOOST_LOG_OPEN_NAMESPACE
- namespace attributes {
- template< typename T >
- class attribute_value_impl :
- public attribute_value::impl
- {
- public:
-
- typedef T value_type;
- private:
-
- const value_type m_value;
- public:
-
- explicit attribute_value_impl(value_type const& v) : m_value(v) {}
-
- explicit attribute_value_impl(BOOST_RV_REF(value_type) v) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible< value_type >::value) :
- m_value(boost::move(v))
- {
- }
-
- bool dispatch(type_dispatcher& dispatcher) BOOST_OVERRIDE
- {
- type_dispatcher::callback< value_type > callback = dispatcher.get_callback< value_type >();
- if (callback)
- {
- callback(m_value);
- return true;
- }
- else
- return false;
- }
-
- typeindex::type_index get_type() const BOOST_OVERRIDE { return typeindex::type_id< value_type >(); }
-
- value_type const& get() const { return m_value; }
- };
- #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
- template< typename T >
- inline attribute_value make_attribute_value(T&& v)
- {
- typedef typename remove_cv< typename remove_reference< T >::type >::type value_type;
- return attribute_value(new attribute_value_impl< value_type >(boost::forward< T >(v)));
- }
- #else
- template< typename T >
- inline attribute_value make_attribute_value(T const& v)
- {
- typedef typename remove_cv< T >::type value_type;
- return attribute_value(new attribute_value_impl< value_type >(v));
- }
- template< typename T >
- inline attribute_value make_attribute_value(rv< T > const& v)
- {
- typedef typename remove_cv< T >::type value_type;
- return attribute_value(new attribute_value_impl< value_type >(v));
- }
- #endif
- }
- BOOST_LOG_CLOSE_NAMESPACE
- }
- #include <boost/log/detail/footer.hpp>
- #endif
|