123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- #ifndef BOOST_LOG_ATTRIBUTES_CONSTANT_HPP_INCLUDED_
- #define BOOST_LOG_ATTRIBUTES_CONSTANT_HPP_INCLUDED_
- #include <boost/move/core.hpp>
- #include <boost/move/utility_core.hpp>
- #include <boost/type_traits/remove_reference.hpp>
- #include <boost/type_traits/is_nothrow_move_constructible.hpp>
- #include <boost/log/detail/config.hpp>
- #include <boost/log/detail/embedded_string_type.hpp>
- #include <boost/log/attributes/attribute.hpp>
- #include <boost/log/attributes/attribute_cast.hpp>
- #include <boost/log/attributes/attribute_value_impl.hpp>
- #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 constant :
- public attribute
- {
- public:
-
- typedef T value_type;
- protected:
-
- class BOOST_SYMBOL_VISIBLE impl :
- public attribute_value_impl< value_type >
- {
-
- typedef attribute_value_impl< value_type > base_type;
- public:
-
- explicit impl(value_type const& value) : base_type(value) {}
-
- explicit impl(BOOST_RV_REF(value_type) value) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible< value_type >::value) :
- base_type(boost::move(value))
- {
- }
- };
- public:
-
- explicit constant(value_type const& value) : attribute(new impl(value)) {}
-
- explicit constant(BOOST_RV_REF(value_type) value) : attribute(new impl(boost::move(value))) {}
-
- explicit constant(cast_source const& source) : attribute(source.as< impl >())
- {
- }
-
- value_type const& get() const
- {
- return static_cast< impl* >(this->get_impl())->get();
- }
- };
- template< typename T >
- inline constant<
- typename boost::log::aux::make_embedded_string_type<
- typename remove_reference< T >::type
- >::type
- > make_constant(BOOST_FWD_REF(T) val)
- {
- typedef typename boost::log::aux::make_embedded_string_type<
- typename remove_reference< T >::type
- >::type value_type;
- return constant< value_type >(boost::forward< T >(val));
- }
- }
- BOOST_LOG_CLOSE_NAMESPACE
- }
- #include <boost/log/detail/footer.hpp>
- #endif
|