diff options
Diffstat (limited to 'boost/log')
28 files changed, 513 insertions, 357 deletions
diff --git a/boost/log/attributes/attribute_value.hpp b/boost/log/attributes/attribute_value.hpp index 95014c19ad..7cc11bfa8e 100644 --- a/boost/log/attributes/attribute_value.hpp +++ b/boost/log/attributes/attribute_value.hpp @@ -15,11 +15,11 @@ #ifndef BOOST_LOG_ATTRIBUTE_VALUE_HPP_INCLUDED_ #define BOOST_LOG_ATTRIBUTE_VALUE_HPP_INCLUDED_ +#include <boost/type_index.hpp> #include <boost/move/core.hpp> #include <boost/smart_ptr/intrusive_ptr.hpp> #include <boost/log/detail/config.hpp> #include <boost/utility/explicit_operator_bool.hpp> -#include <boost/log/utility/type_info_wrapper.hpp> #include <boost/log/utility/type_dispatch/type_dispatcher.hpp> #include <boost/log/attributes/attribute.hpp> #include <boost/log/attributes/value_extraction_fwd.hpp> @@ -103,7 +103,7 @@ public: /*! * \return The attribute value type */ - virtual type_info_wrapper get_type() const { return type_info_wrapper(); } + virtual typeindex::type_index get_type() const { return typeindex::type_index(); } }; private: @@ -166,12 +166,12 @@ public: * the information cannot be provided. If the returned value is not empty, the type * can be used for value extraction. */ - type_info_wrapper get_type() const + typeindex::type_index get_type() const { if (m_pImpl.get()) return m_pImpl->get_type(); else - return type_info_wrapper(); + return typeindex::type_index(); } /*! diff --git a/boost/log/attributes/attribute_value_impl.hpp b/boost/log/attributes/attribute_value_impl.hpp index 99bf022e72..50ba812271 100644 --- a/boost/log/attributes/attribute_value_impl.hpp +++ b/boost/log/attributes/attribute_value_impl.hpp @@ -15,6 +15,7 @@ #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.hpp> #include <boost/type_traits/remove_cv.hpp> @@ -87,7 +88,7 @@ public: /*! * \return The attribute value type */ - type_info_wrapper get_type() const { return type_info_wrapper(typeid(value_type)); } + typeindex::type_index get_type() const { return typeindex::type_id< value_type >(); } /*! * \return Reference to the contained value. diff --git a/boost/log/attributes/current_thread_id.hpp b/boost/log/attributes/current_thread_id.hpp index 0861a370be..23573e38be 100644 --- a/boost/log/attributes/current_thread_id.hpp +++ b/boost/log/attributes/current_thread_id.hpp @@ -79,7 +79,7 @@ protected: return new detached_value(boost::log::aux::this_thread::get_id()); } - type_info_wrapper get_type() const { return type_info_wrapper(typeid(value_type)); } + typeindex::type_index get_type() const { return typeindex::type_id< value_type >(); } }; public: diff --git a/boost/log/attributes/fallback_policy.hpp b/boost/log/attributes/fallback_policy.hpp index 549b81df9f..cde3e94623 100644 --- a/boost/log/attributes/fallback_policy.hpp +++ b/boost/log/attributes/fallback_policy.hpp @@ -15,11 +15,11 @@ #ifndef BOOST_LOG_ATTRIBUTES_FALLBACK_POLICY_HPP_INCLUDED_ #define BOOST_LOG_ATTRIBUTES_FALLBACK_POLICY_HPP_INCLUDED_ +#include <boost/type_index.hpp> #include <boost/type_traits/remove_cv.hpp> #include <boost/type_traits/remove_reference.hpp> #include <boost/log/detail/config.hpp> #include <boost/log/exceptions.hpp> -#include <boost/log/utility/type_info_wrapper.hpp> #include <boost/log/attributes/fallback_policy_fwd.hpp> #include <boost/log/detail/header.hpp> @@ -59,7 +59,7 @@ struct fallback_to_none /*! * The method is called when value extraction failed because the attribute value has different type than requested. */ - static void on_invalid_type(type_info_wrapper const&) + static void on_invalid_type(typeindex::type_index const&) { } @@ -99,7 +99,7 @@ struct fallback_to_throw /*! * The method is called when value extraction failed because the attribute value has different type than requested. */ - static void on_invalid_type(type_info_wrapper const& t) + static void on_invalid_type(typeindex::type_index const& t) { BOOST_LOG_THROW_DESCR_PARAMS(invalid_type, "Attribute value has incompatible type", (t)); } @@ -161,7 +161,7 @@ struct fallback_to_default /*! * The method is called when value extraction failed because the attribute value has different type than requested. */ - static void on_invalid_type(type_info_wrapper const&) + static void on_invalid_type(typeindex::type_index const&) { } diff --git a/boost/log/core/record_view.hpp b/boost/log/core/record_view.hpp index 613f93dab3..6fa7a63f98 100644 --- a/boost/log/core/record_view.hpp +++ b/boost/log/core/record_view.hpp @@ -88,8 +88,8 @@ private: BOOST_DELETED_FUNCTION(public_data(public_data const&)) BOOST_DELETED_FUNCTION(public_data& operator= (public_data const&)) - friend void intrusive_ptr_add_ref(const public_data* p) { ++p->m_ref_counter; } - friend void intrusive_ptr_release(const public_data* p) { if (--p->m_ref_counter == 0) public_data::destroy(p); } + friend void intrusive_ptr_add_ref(const public_data* p) BOOST_NOEXCEPT { ++p->m_ref_counter; } + friend void intrusive_ptr_release(const public_data* p) BOOST_NOEXCEPT { if (--p->m_ref_counter == 0) public_data::destroy(p); } }; private: diff --git a/boost/log/detail/code_conversion.hpp b/boost/log/detail/code_conversion.hpp index 4c39f9c02b..41c086e109 100644 --- a/boost/log/detail/code_conversion.hpp +++ b/boost/log/detail/code_conversion.hpp @@ -16,9 +16,12 @@ #ifndef BOOST_LOG_DETAIL_CODE_CONVERSION_HPP_INCLUDED_ #define BOOST_LOG_DETAIL_CODE_CONVERSION_HPP_INCLUDED_ +#include <cstddef> #include <locale> #include <string> +#include <boost/core/enable_if.hpp> #include <boost/log/detail/config.hpp> +#include <boost/log/detail/is_character_type.hpp> #include <boost/log/detail/header.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE @@ -32,44 +35,64 @@ BOOST_LOG_OPEN_NAMESPACE namespace aux { //! The function converts one string to the character type of another -BOOST_LOG_API void code_convert(const wchar_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale()); +BOOST_LOG_API void code_convert_impl(const wchar_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale()); //! The function converts one string to the character type of another -BOOST_LOG_API void code_convert(const char* str1, std::size_t len, std::wstring& str2, std::locale const& loc = std::locale()); +BOOST_LOG_API void code_convert_impl(const char* str1, std::size_t len, std::wstring& str2, std::locale const& loc = std::locale()); -// Note: MSVC 2015 (aka VC14) implement char16_t and char32_t types but not codecvt locale facets -#if !defined(BOOST_MSVC) +#if !defined(BOOST_LOG_NO_CXX11_CODECVT_FACETS) #if !defined(BOOST_NO_CXX11_CHAR16_T) //! The function converts one string to the character type of another -BOOST_LOG_API void code_convert(const char16_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale()); +BOOST_LOG_API void code_convert_impl(const char16_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale()); //! The function converts one string to the character type of another -BOOST_LOG_API void code_convert(const char* str1, std::size_t len, std::u16string& str2, std::locale const& loc = std::locale()); +BOOST_LOG_API void code_convert_impl(const char* str1, std::size_t len, std::u16string& str2, std::locale const& loc = std::locale()); +//! The function converts one string to the character type of another +BOOST_LOG_API void code_convert_impl(const char16_t* str1, std::size_t len, std::wstring& str2, std::locale const& loc = std::locale()); #endif #if !defined(BOOST_NO_CXX11_CHAR32_T) //! The function converts one string to the character type of another -BOOST_LOG_API void code_convert(const char32_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale()); +BOOST_LOG_API void code_convert_impl(const char32_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale()); +//! The function converts one string to the character type of another +BOOST_LOG_API void code_convert_impl(const char* str1, std::size_t len, std::u32string& str2, std::locale const& loc = std::locale()); +//! The function converts one string to the character type of another +BOOST_LOG_API void code_convert_impl(const char32_t* str1, std::size_t len, std::wstring& str2, std::locale const& loc = std::locale()); +#endif +#if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_CHAR32_T) +//! The function converts one string to the character type of another +BOOST_LOG_API void code_convert_impl(const char16_t* str1, std::size_t len, std::u32string& str2, std::locale const& loc = std::locale()); //! The function converts one string to the character type of another -BOOST_LOG_API void code_convert(const char* str1, std::size_t len, std::u32string& str2, std::locale const& loc = std::locale()); +BOOST_LOG_API void code_convert_impl(const char32_t* str1, std::size_t len, std::u16string& str2, std::locale const& loc = std::locale()); #endif -#endif // !defined(BOOST_MSVC) +#endif // !defined(BOOST_LOG_NO_CXX11_CODECVT_FACETS) //! The function converts one string to the character type of another -template< typename CharT, typename SourceTraitsT, typename SourceAllocatorT, typename TargetTraitsT, typename TargetAllocatorT > -inline void code_convert(std::basic_string< CharT, SourceTraitsT, SourceAllocatorT > const& str1, std::basic_string< CharT, TargetTraitsT, TargetAllocatorT >& str2, std::locale const& = std::locale()) +template< typename SourceCharT, typename SourceTraitsT, typename SourceAllocatorT, typename TargetCharT, typename TargetTraitsT, typename TargetAllocatorT > +inline typename boost::enable_if_c< is_character_type< SourceCharT >::value && is_character_type< TargetCharT >::value && sizeof(SourceCharT) == sizeof(TargetCharT) >::type +code_convert(std::basic_string< SourceCharT, SourceTraitsT, SourceAllocatorT > const& str1, std::basic_string< TargetCharT, TargetTraitsT, TargetAllocatorT >& str2, std::locale const& = std::locale()) { - str2.append(str1.c_str(), str1.size()); + str2.append(reinterpret_cast< const TargetCharT* >(str1.c_str()), str1.size()); } //! The function converts one string to the character type of another -template< typename CharT, typename TargetTraitsT, typename TargetAllocatorT > -inline void code_convert(const CharT* str1, std::size_t len, std::basic_string< CharT, TargetTraitsT, TargetAllocatorT >& str2, std::locale const& = std::locale()) +template< typename SourceCharT, typename TargetCharT, typename TargetTraitsT, typename TargetAllocatorT > +inline typename boost::enable_if_c< is_character_type< SourceCharT >::value && is_character_type< TargetCharT >::value && sizeof(SourceCharT) == sizeof(TargetCharT) >::type +code_convert(const SourceCharT* str1, std::size_t len, std::basic_string< TargetCharT, TargetTraitsT, TargetAllocatorT >& str2, std::locale const& = std::locale()) { - str2.append(str1, len); + str2.append(reinterpret_cast< const TargetCharT* >(str1), len); } //! The function converts one string to the character type of another template< typename SourceCharT, typename SourceTraitsT, typename SourceAllocatorT, typename TargetCharT, typename TargetTraitsT, typename TargetAllocatorT > -inline void code_convert(std::basic_string< SourceCharT, SourceTraitsT, SourceAllocatorT > const& str1, std::basic_string< TargetCharT, TargetTraitsT, TargetAllocatorT >& str2, std::locale const& loc = std::locale()) +inline typename boost::enable_if_c< is_character_type< SourceCharT >::value && is_character_type< TargetCharT >::value && sizeof(SourceCharT) != sizeof(TargetCharT) >::type +code_convert(std::basic_string< SourceCharT, SourceTraitsT, SourceAllocatorT > const& str1, std::basic_string< TargetCharT, TargetTraitsT, TargetAllocatorT >& str2, std::locale const& loc = std::locale()) +{ + aux::code_convert_impl(str1.c_str(), str1.size(), str2, loc); +} + +//! The function converts one string to the character type of another +template< typename SourceCharT, typename TargetCharT, typename TargetTraitsT, typename TargetAllocatorT > +inline typename boost::enable_if_c< is_character_type< SourceCharT >::value && is_character_type< TargetCharT >::value && sizeof(SourceCharT) != sizeof(TargetCharT) >::type +code_convert(const SourceCharT* str1, std::size_t len, std::basic_string< TargetCharT, TargetTraitsT, TargetAllocatorT >& str2, std::locale const& loc = std::locale()) { - aux::code_convert(str1.c_str(), str1.size(), str2, loc); + aux::code_convert_impl(str1, len, str2, loc); } //! The function converts the passed string to the narrow-character encoding diff --git a/boost/log/detail/config.hpp b/boost/log/detail/config.hpp index c5a73679ae..64b4412383 100644 --- a/boost/log/detail/config.hpp +++ b/boost/log/detail/config.hpp @@ -96,6 +96,13 @@ # define BOOST_LOG_BROKEN_CONSTANT_EXPRESSIONS #endif +#if defined(BOOST_NO_CXX11_HDR_CODECVT) + // The compiler does not support std::codecvt<char16_t> and std::codecvt<char32_t> specializations. + // The BOOST_NO_CXX11_HDR_CODECVT means there's no usable <codecvt>, which is slightly different from this macro. + // But in order for <codecvt> to be implemented the std::codecvt specializations have to be implemented as well. +# define BOOST_LOG_NO_CXX11_CODECVT_FACETS +#endif + #if defined(__CYGWIN__) // Boost.ASIO is broken on Cygwin # define BOOST_LOG_NO_ASIO diff --git a/boost/log/detail/event.hpp b/boost/log/detail/event.hpp index 4bb49822c1..0168e170e7 100644 --- a/boost/log/detail/event.hpp +++ b/boost/log/detail/event.hpp @@ -22,12 +22,15 @@ #ifndef BOOST_LOG_NO_THREADS #if defined(BOOST_THREAD_PLATFORM_PTHREAD) -# if defined(_POSIX_SEMAPHORES) && (_POSIX_SEMAPHORES + 0) > 0 -# if defined(__GNUC__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) -# include <semaphore.h> -# include <boost/cstdint.hpp> -# define BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE -# endif +# include <boost/atomic/capabilities.hpp> +# if (defined(linux) || defined(__linux) || defined(__linux__)) && BOOST_ATOMIC_INT_LOCK_FREE == 2 +# include <boost/atomic/atomic.hpp> +# define BOOST_LOG_EVENT_USE_FUTEX +# elif defined(_POSIX_SEMAPHORES) && (_POSIX_SEMAPHORES + 0) > 0 && BOOST_ATOMIC_FLAG_LOCK_FREE == 2 +# include <semaphore.h> +# include <boost/cstdint.hpp> +# include <boost/atomic/atomic_flag.hpp> +# define BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE # endif #elif defined(BOOST_THREAD_PLATFORM_WIN32) # include <boost/cstdint.hpp> @@ -48,12 +51,37 @@ BOOST_LOG_OPEN_NAMESPACE namespace aux { -#if defined(BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE) +#if defined(BOOST_LOG_EVENT_USE_FUTEX) + +class futex_based_event +{ +private: + boost::atomic< int > m_state; + +public: + //! Default constructor + BOOST_LOG_API futex_based_event(); + //! Destructor + BOOST_LOG_API ~futex_based_event(); + + //! Waits for the object to become signalled + BOOST_LOG_API void wait(); + //! Sets the object to a signalled state + BOOST_LOG_API void set_signalled(); + + // Copying prohibited + BOOST_DELETED_FUNCTION(futex_based_event(futex_based_event const&)) + BOOST_DELETED_FUNCTION(futex_based_event& operator= (futex_based_event const&)) +}; + +typedef futex_based_event event; + +#elif defined(BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE) class sem_based_event { private: - boost::uint32_t m_state; + boost::atomic_flag m_state; sem_t m_semaphore; public: diff --git a/boost/log/detail/is_character_type.hpp b/boost/log/detail/is_character_type.hpp new file mode 100644 index 0000000000..29f7dccd55 --- /dev/null +++ b/boost/log/detail/is_character_type.hpp @@ -0,0 +1,75 @@ +/* + * Copyright Andrey Semashev 2007 - 2015. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ +/*! + * \file is_character_type.hpp + * \author Andrey Semashev + * \date 25.07.2015 + * + * The header defines \c is_character_type trait which checks if the type is one of the character types + */ + +#ifndef BOOST_LOG_DETAIL_IS_CHARACTER_TYPE_HPP_INCLUDED_ +#define BOOST_LOG_DETAIL_IS_CHARACTER_TYPE_HPP_INCLUDED_ + +#include <boost/log/detail/config.hpp> +#include <boost/log/detail/header.hpp> + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace boost { + +BOOST_LOG_OPEN_NAMESPACE + +namespace aux { + +template< typename T > +struct is_character_type +{ + static BOOST_CONSTEXPR_OR_CONST bool value = false; +}; + +template< > +struct is_character_type< char > +{ + static BOOST_CONSTEXPR_OR_CONST bool value = true; +}; + +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) +template< > +struct is_character_type< wchar_t > +{ + static BOOST_CONSTEXPR_OR_CONST bool value = true; +}; +#endif + +#if !defined(BOOST_NO_CXX11_CHAR16_T) +template< > +struct is_character_type< char16_t > +{ + static BOOST_CONSTEXPR_OR_CONST bool value = true; +}; +#endif + +#if !defined(BOOST_NO_CXX11_CHAR32_T) +template< > +struct is_character_type< char32_t > +{ + static BOOST_CONSTEXPR_OR_CONST bool value = true; +}; +#endif + +} // namespace aux + +BOOST_LOG_CLOSE_NAMESPACE // namespace log + +} // namespace boost + +#include <boost/log/detail/footer.hpp> + +#endif // BOOST_LOG_DETAIL_IS_CHARACTER_TYPE_HPP_INCLUDED_ diff --git a/boost/log/detail/visible_type.hpp b/boost/log/detail/is_ostream.hpp index 79f4007d2a..2131baebb5 100644 --- a/boost/log/detail/visible_type.hpp +++ b/boost/log/detail/is_ostream.hpp @@ -5,19 +5,23 @@ * http://www.boost.org/LICENSE_1_0.txt) */ /*! - * \file visible_type.hpp + * \file is_ostream.hpp * \author Andrey Semashev - * \date 08.03.2007 + * \date 05.07.2015 * * \brief This header is the Boost.Log library implementation, see the library documentation * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. In this file * internal configuration macros are defined. */ -#ifndef BOOST_LOG_DETAIL_VISIBLE_TYPE_HPP_INCLUDED_ -#define BOOST_LOG_DETAIL_VISIBLE_TYPE_HPP_INCLUDED_ +#ifndef BOOST_LOG_DETAIL_IS_OSTREAM_HPP_INCLUDED_ +#define BOOST_LOG_DETAIL_IS_OSTREAM_HPP_INCLUDED_ +#include <iosfwd> +#include <boost/type_traits/is_base_of.hpp> +#include <boost/type_traits/has_left_shift.hpp> #include <boost/log/detail/config.hpp> +#include <boost/log/utility/formatting_ostream_fwd.hpp> #include <boost/log/detail/header.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE @@ -30,11 +34,16 @@ BOOST_LOG_OPEN_NAMESPACE namespace aux { -//! The wrapper type whose type_info is always visible template< typename T > -struct BOOST_SYMBOL_VISIBLE visible_type +struct is_ostream { - typedef T wrapped_type; + static BOOST_CONSTEXPR_OR_CONST bool value = is_base_of< std::ios_base, T >::value && has_left_shift< T, int >::value; +}; + +template< typename CharT, typename TraitsT, typename AllocatorT > +struct is_ostream< basic_formatting_ostream< CharT, TraitsT, AllocatorT > > +{ + static BOOST_CONSTEXPR_OR_CONST bool value = true; }; } // namespace aux @@ -45,4 +54,4 @@ BOOST_LOG_CLOSE_NAMESPACE // namespace log #include <boost/log/detail/footer.hpp> -#endif // BOOST_LOG_DETAIL_VISIBLE_TYPE_HPP_INCLUDED_ +#endif // BOOST_LOG_DETAIL_IS_OSTREAM_HPP_INCLUDED_ diff --git a/boost/log/exceptions.hpp b/boost/log/exceptions.hpp index f5bcbc436e..8f305fabeb 100644 --- a/boost/log/exceptions.hpp +++ b/boost/log/exceptions.hpp @@ -18,10 +18,10 @@ #include <cstddef> #include <string> #include <stdexcept> +#include <boost/type_index.hpp> #include <boost/preprocessor/seq/enum.hpp> #include <boost/log/detail/config.hpp> #include <boost/log/attributes/attribute_name.hpp> -#include <boost/log/utility/type_info_wrapper.hpp> #include <boost/log/detail/header.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE @@ -130,8 +130,8 @@ public: static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name); - static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, type_info_wrapper const& type); - static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name, type_info_wrapper const& type); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, typeindex::type_index const& type); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name, typeindex::type_index const& type); #endif }; diff --git a/boost/log/expressions/formatters/c_decorator.hpp b/boost/log/expressions/formatters/c_decorator.hpp index 9c2b62d726..ec3f485405 100644 --- a/boost/log/expressions/formatters/c_decorator.hpp +++ b/boost/log/expressions/formatters/c_decorator.hpp @@ -60,7 +60,7 @@ struct c_decorator_traits< char > template< unsigned int N > static std::size_t print_escaped(char (&buf)[N], char c) { - int n = boost::log::aux::snprintf(buf, N, "\\x%0.2X", static_cast< unsigned int >(static_cast< uint8_t >(c))); + int n = boost::log::aux::snprintf(buf, N, "\\x%.2X", static_cast< unsigned int >(static_cast< uint8_t >(c))); if (n < 0) { n = 0; @@ -98,17 +98,17 @@ struct c_decorator_traits< wchar_t > unsigned int val; if (sizeof(wchar_t) == 1) { - format = L"\\x%0.2X"; + format = L"\\x%.2X"; val = static_cast< uint8_t >(c); } else if (sizeof(wchar_t) == 2) { - format = L"\\x%0.4X"; + format = L"\\x%.4X"; val = static_cast< uint16_t >(c); } else { - format = L"\\x%0.8X"; + format = L"\\x%.8X"; val = static_cast< uint32_t >(c); } @@ -148,7 +148,7 @@ struct c_decorator_gen * can be used to construct the actual decorator. For example: * * <code> - * c_decor[ attr< std::string >("MyAttr") ] + * c_decor[ stream << attr< std::string >("MyAttr") ] * </code> * * For wide-character formatting there is the similar \c wc_decor decorator generator object. @@ -231,7 +231,6 @@ struct c_ascii_decorator_gen template< typename SubactorT > BOOST_FORCEINLINE char_decorator_actor< SubactorT, c_ascii_pattern_replacer< char_type > > operator[] (SubactorT const& subactor) const { - typedef c_decorator_traits< char_type > traits_type; typedef c_ascii_pattern_replacer< char_type > replacer_type; typedef char_decorator_actor< SubactorT, replacer_type > result_type; typedef typename result_type::terminal_type terminal_type; @@ -249,7 +248,7 @@ struct c_ascii_decorator_gen * can be used to construct the actual decorator. For example: * * <code> - * c_ascii_decor[ attr< std::string >("MyAttr") ] + * c_ascii_decor[ stream << attr< std::string >("MyAttr") ] * </code> * * For wide-character formatting there is the similar \c wc_ascii_decor decorator generator object. diff --git a/boost/log/expressions/formatters/csv_decorator.hpp b/boost/log/expressions/formatters/csv_decorator.hpp index e28daf2e2e..a4c1c28399 100644 --- a/boost/log/expressions/formatters/csv_decorator.hpp +++ b/boost/log/expressions/formatters/csv_decorator.hpp @@ -108,7 +108,7 @@ struct csv_decorator_gen * the actual decorator. For example: * * <code> - * csv_decor[ attr< std::string >("MyAttr") ] + * csv_decor[ stream << attr< std::string >("MyAttr") ] * </code> * * For wide-character formatting there is the similar \c wcsv_decor decorator generator object. diff --git a/boost/log/expressions/formatters/xml_decorator.hpp b/boost/log/expressions/formatters/xml_decorator.hpp index 0a7613328a..ca93a7d58a 100644 --- a/boost/log/expressions/formatters/xml_decorator.hpp +++ b/boost/log/expressions/formatters/xml_decorator.hpp @@ -106,7 +106,7 @@ struct xml_decorator_gen * <tt>operator[]</tt> that can be used to construct the actual decorator. For example: * * <code> - * xml_decor[ attr< std::string >("MyAttr") ] + * xml_decor[ stream << attr< std::string >("MyAttr") ] * </code> * * For wide-character formatting there is the similar \c wxml_decor decorator generator object. diff --git a/boost/log/sinks/event_log_backend.hpp b/boost/log/sinks/event_log_backend.hpp index 08d211cea7..5378295160 100644 --- a/boost/log/sinks/event_log_backend.hpp +++ b/boost/log/sinks/event_log_backend.hpp @@ -562,7 +562,7 @@ public: * The following named parameters are supported: * * \li \c message_file - Specifies the file name that contains resources that - * describe events and categories. + * describe events and categories. This parameter is mandatory unless \c registration is \c never. * \li \c target - Specifies an UNC path to the remote server to which log records should be sent to. * The local machine will be used to process log records, if not specified. * \li \c log_name - Specifies the log in which the source should be registered. @@ -625,7 +625,7 @@ private: void construct(ArgsT const& args) { construct( - filesystem::path(args[keywords::message_file]), + filesystem::path(args[keywords::message_file | filesystem::path()]), args[keywords::target | string_type()], args[keywords::log_name || &basic_event_log_backend::get_default_log_name], args[keywords::log_source || &basic_event_log_backend::get_default_source_name], diff --git a/boost/log/sources/global_logger_storage.hpp b/boost/log/sources/global_logger_storage.hpp index ffbc4313e3..a98e5e63e1 100644 --- a/boost/log/sources/global_logger_storage.hpp +++ b/boost/log/sources/global_logger_storage.hpp @@ -15,14 +15,13 @@ #ifndef BOOST_LOG_SOURCES_GLOBAL_LOGGER_STORAGE_HPP_INCLUDED_ #define BOOST_LOG_SOURCES_GLOBAL_LOGGER_STORAGE_HPP_INCLUDED_ -#include <typeinfo> #include <stdexcept> +#include <boost/type_index.hpp> #include <boost/smart_ptr/shared_ptr.hpp> #include <boost/smart_ptr/make_shared_object.hpp> #include <boost/preprocessor/seq/enum.hpp> #include <boost/log/detail/config.hpp> #include <boost/log/detail/singleton.hpp> -#include <boost/log/detail/visible_type.hpp> #include <boost/log/detail/header.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE @@ -41,17 +40,19 @@ namespace aux { struct BOOST_LOG_NO_VTABLE BOOST_SYMBOL_VISIBLE logger_holder_base { //! The source file name where the logger was registered - const char* m_RegistrationFile; + const char* const m_RegistrationFile; //! The line number where the logger was registered - unsigned int m_RegistrationLine; + const unsigned int m_RegistrationLine; + //! Stored logger type + const typeindex::type_index m_LoggerType; - logger_holder_base(const char* file, unsigned int line) : + logger_holder_base(const char* file, unsigned int line, typeindex::type_index logger_type) BOOST_NOEXCEPT : m_RegistrationFile(file), - m_RegistrationLine(line) + m_RegistrationLine(line), + m_LoggerType(logger_type) { } virtual ~logger_holder_base() {} - virtual std::type_info const& logger_type() const = 0; }; //! The actual logger holder class @@ -63,11 +64,10 @@ struct BOOST_SYMBOL_VISIBLE logger_holder : LoggerT m_Logger; logger_holder(const char* file, unsigned int line, LoggerT const& logger) : - logger_holder_base(file, line), + logger_holder_base(file, line, typeindex::type_id< LoggerT >()), m_Logger(logger) { } - std::type_info const& logger_type() const { return typeid(LoggerT); } }; //! The class implements a global repository of tagged loggers @@ -76,7 +76,7 @@ struct global_storage typedef shared_ptr< logger_holder_base >(*initializer_t)(); //! Finds or creates the logger and returns its holder - BOOST_LOG_API static shared_ptr< logger_holder_base > get_or_init(std::type_info const& key, initializer_t initializer); + BOOST_LOG_API static shared_ptr< logger_holder_base > get_or_init(typeindex::type_index key, initializer_t initializer); // Non-constructible, non-copyable, non-assignable BOOST_DELETED_FUNCTION(global_storage()) @@ -86,8 +86,8 @@ struct global_storage //! Throws the \c odr_violation exception BOOST_LOG_API BOOST_LOG_NORETURN void throw_odr_violation( - std::type_info const& tag_type, - std::type_info const& logger_type, + typeindex::type_index tag_type, + typeindex::type_index logger_type, logger_holder_base const& registered); //! The class implements a logger singleton @@ -116,18 +116,24 @@ struct logger_singleton : static void init_instance() { shared_ptr< logger_holder< logger_type > >& instance = base_type::get_instance(); - shared_ptr< logger_holder_base > holder = global_storage::get_or_init( - typeid(boost::log::aux::visible_type< TagT >), - &logger_singleton::construct_logger); - instance = boost::dynamic_pointer_cast< logger_holder< logger_type > >(holder); - if (!instance) + const typeindex::type_index tag_type_index = typeindex::type_id< TagT >(); + shared_ptr< logger_holder_base > holder = global_storage::get_or_init(tag_type_index, &logger_singleton::construct_logger); + const typeindex::type_index logger_type_index = typeindex::type_id< logger_type >(); + if (holder->m_LoggerType == logger_type_index) + { + // Note: dynamic_cast may fail here if logger_type is not visible (for example, with Clang on Linux, if the original logger + // instance was initialized in a different DSO than where it's being queried). logger_holder default visibility doesn't + // help since it is inhibited by the template parameter visibility. + instance = boost::static_pointer_cast< logger_holder< logger_type > >(holder); + } + else { // In pure C++ this should never happen, since there cannot be two // different tag types that have equal type_infos. In real life it can // happen if the same-named tag is defined differently in two or more // dlls. This check is intended to detect such ODR violations. However, there // is no protection against different definitions of the logger type itself. - throw_odr_violation(typeid(TagT), typeid(logger_type), *holder); + throw_odr_violation(tag_type_index, logger_type_index, *holder); } } diff --git a/boost/log/support/exception.hpp b/boost/log/support/exception.hpp index e880115ee6..f6d9be20d5 100644 --- a/boost/log/support/exception.hpp +++ b/boost/log/support/exception.hpp @@ -15,11 +15,11 @@ #ifndef BOOST_LOG_SUPPORT_EXCEPTION_HPP_INCLUDED_ #define BOOST_LOG_SUPPORT_EXCEPTION_HPP_INCLUDED_ +#include <boost/type_index.hpp> #include <boost/exception/info.hpp> #include <boost/log/detail/config.hpp> #include <boost/log/attributes/attribute_name.hpp> #include <boost/log/attributes/named_scope.hpp> -#include <boost/log/utility/type_info_wrapper.hpp> #include <boost/log/detail/header.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE @@ -38,7 +38,7 @@ typedef error_info< struct attribute_name_info_tag, attribute_name > attribute_n /*! * Type info exception information */ -typedef error_info< struct type_info_info_tag, type_info_wrapper > type_info_info; +typedef error_info< struct type_info_info_tag, typeindex::type_index > type_info_info; /*! * Parse position exception information diff --git a/boost/log/utility/empty_deleter.hpp b/boost/log/utility/empty_deleter.hpp deleted file mode 100644 index 09bf29c7e8..0000000000 --- a/boost/log/utility/empty_deleter.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright Andrey Semashev 2007 - 2015. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -/*! - * \file empty_deleter.hpp - * \author Andrey Semashev - * \date 22.04.2007 - * - * This header is deprecated, use boost/utility/empty_deleter.hpp instead. The header is left for - * backward compatibility and will be removed in future versions. - */ - -#ifndef BOOST_LOG_UTILITY_EMPTY_DELETER_HPP_INCLUDED_ -#define BOOST_LOG_UTILITY_EMPTY_DELETER_HPP_INCLUDED_ - -#include <boost/core/null_deleter.hpp> -#include <boost/log/detail/config.hpp> - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -#if defined(__GNUC__) -#pragma message "Boost.Log: This header is deprecated, use boost/core/null_deleter.hpp instead." -#elif defined(_MSC_VER) -#pragma message("Boost.Log: This header is deprecated, use boost/core/null_deleter.hpp instead.") -#endif - -namespace boost { - -BOOST_LOG_OPEN_NAMESPACE - -typedef boost::null_deleter empty_deleter; - -BOOST_LOG_CLOSE_NAMESPACE // namespace log - -} // namespace boost - -#endif // BOOST_LOG_UTILITY_EMPTY_DELETER_HPP_INCLUDED_ diff --git a/boost/log/utility/explicit_operator_bool.hpp b/boost/log/utility/explicit_operator_bool.hpp deleted file mode 100644 index d30aff6070..0000000000 --- a/boost/log/utility/explicit_operator_bool.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright Andrey Semashev 2007 - 2015. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -/*! - * \file explicit_operator_bool.hpp - * \author Andrey Semashev - * \date 08.03.2009 - * - * This header is deprecated, use boost/utility/explicit_operator_bool.hpp instead. The header is left for - * backward compatibility and will be removed in future versions. - */ - -#ifndef BOOST_LOG_UTILITY_EXPLICIT_OPERATOR_BOOL_HPP_INCLUDED_ -#define BOOST_LOG_UTILITY_EXPLICIT_OPERATOR_BOOL_HPP_INCLUDED_ - -#include <boost/utility/explicit_operator_bool.hpp> -#include <boost/log/detail/config.hpp> - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -#if defined(__GNUC__) -#pragma message "Boost.Log: This header is deprecated, use boost/utility/explicit_operator_bool.hpp instead." -#elif defined(_MSC_VER) -#pragma message("Boost.Log: This header is deprecated, use boost/utility/explicit_operator_bool.hpp instead.") -#endif - -/*! - * \brief The macro defines an explicit operator of conversion to \c bool - * - * The macro should be used inside the definition of a class that has to - * support the conversion. The class should also implement <tt>operator!</tt>, - * in terms of which the conversion operator will be implemented. - */ -#define BOOST_LOG_EXPLICIT_OPERATOR_BOOL()\ - BOOST_EXPLICIT_OPERATOR_BOOL() - -#endif // BOOST_LOG_UTILITY_EXPLICIT_OPERATOR_BOOL_HPP_INCLUDED_ diff --git a/boost/log/utility/formatting_ostream.hpp b/boost/log/utility/formatting_ostream.hpp index 13f367f791..4345206f12 100644 --- a/boost/log/utility/formatting_ostream.hpp +++ b/boost/log/utility/formatting_ostream.hpp @@ -19,6 +19,7 @@ #include <string> #include <memory> #include <locale> +#include <boost/core/explicit_operator_bool.hpp> #include <boost/utility/string_ref_fwd.hpp> #include <boost/type_traits/remove_cv.hpp> #include <boost/log/detail/config.hpp> @@ -26,7 +27,6 @@ #include <boost/log/detail/code_conversion.hpp> #include <boost/log/utility/string_literal_fwd.hpp> #include <boost/log/utility/formatting_ostream_fwd.hpp> -#include <boost/utility/explicit_operator_bool.hpp> #include <boost/log/detail/header.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE @@ -40,19 +40,26 @@ BOOST_LOG_OPEN_NAMESPACE namespace aux { template< typename T, typename R > -struct enable_if_char_type {}; +struct enable_if_streamable_char_type {}; template< typename R > -struct enable_if_char_type< char, R > { typedef R type; }; +struct enable_if_streamable_char_type< char, R > { typedef R type; }; template< typename R > -struct enable_if_char_type< wchar_t, R > { typedef R type; }; +struct enable_if_streamable_char_type< wchar_t, R > { typedef R type; }; +#if !defined(BOOST_LOG_NO_CXX11_CODECVT_FACETS) #if !defined(BOOST_NO_CXX11_CHAR16_T) template< typename R > -struct enable_if_char_type< char16_t, R > { typedef R type; }; +struct enable_if_streamable_char_type< char16_t, R > { typedef R type; }; #endif #if !defined(BOOST_NO_CXX11_CHAR32_T) template< typename R > -struct enable_if_char_type< char32_t, R > { typedef R type; }; +struct enable_if_streamable_char_type< char32_t, R > { typedef R type; }; #endif +#endif + +template< typename StreamT, typename R > +struct enable_if_formatting_ostream {}; +template< typename CharT, typename TraitsT, typename AllocatorT, typename R > +struct enable_if_formatting_ostream< basic_formatting_ostream< CharT, TraitsT, AllocatorT >, R > { typedef R type; }; } // namespace aux @@ -338,7 +345,7 @@ public: } template< typename OtherCharT > - typename aux::enable_if_char_type< OtherCharT, basic_formatting_ostream& >::type + typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type put(OtherCharT c) { write(&c, 1); @@ -352,7 +359,7 @@ public: } template< typename OtherCharT > - typename aux::enable_if_char_type< OtherCharT, basic_formatting_ostream& >::type + typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type write(const OtherCharT* p, std::streamsize size) { sentry guard(*this); @@ -402,6 +409,7 @@ public: return this->formatted_write(p, static_cast< std::streamsize >(std::char_traits< wchar_t >::length(p))); } #endif +#if !defined(BOOST_LOG_NO_CXX11_CODECVT_FACETS) #if !defined(BOOST_NO_CXX11_CHAR16_T) basic_formatting_ostream& operator<< (char16_t c) { @@ -422,6 +430,7 @@ public: return this->formatted_write(p, static_cast< std::streamsize >(std::char_traits< char32_t >::length(p))); } #endif +#endif basic_formatting_ostream& operator<< (bool value) { @@ -510,26 +519,91 @@ public: } template< typename OtherCharT, typename OtherTraitsT, typename OtherAllocatorT > - friend typename aux::enable_if_char_type< OtherCharT, basic_formatting_ostream& >::type + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type operator<< (basic_formatting_ostream& strm, std::basic_string< OtherCharT, OtherTraitsT, OtherAllocatorT > const& str) { return strm.formatted_write(str.c_str(), static_cast< std::streamsize >(str.size())); } template< typename OtherCharT, typename OtherTraitsT > - friend typename aux::enable_if_char_type< OtherCharT, basic_formatting_ostream& >::type + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type operator<< (basic_formatting_ostream& strm, basic_string_literal< OtherCharT, OtherTraitsT > const& str) { return strm.formatted_write(str.c_str(), static_cast< std::streamsize >(str.size())); } template< typename OtherCharT, typename OtherTraitsT > - friend typename aux::enable_if_char_type< OtherCharT, basic_formatting_ostream& >::type + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type operator<< (basic_formatting_ostream& strm, basic_string_ref< OtherCharT, OtherTraitsT > const& str) { return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size())); } + template< typename OtherCharT, typename OtherTraitsT, typename OtherAllocatorT > + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type + operator<< (basic_formatting_ostream& strm, std::basic_string< OtherCharT, OtherTraitsT, OtherAllocatorT >& str) + { + return strm.formatted_write(str.c_str(), static_cast< std::streamsize >(str.size())); + } + + template< typename OtherCharT, typename OtherTraitsT > + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type + operator<< (basic_formatting_ostream& strm, basic_string_literal< OtherCharT, OtherTraitsT >& str) + { + return strm.formatted_write(str.c_str(), static_cast< std::streamsize >(str.size())); + } + + template< typename OtherCharT, typename OtherTraitsT > + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type + operator<< (basic_formatting_ostream& strm, basic_string_ref< OtherCharT, OtherTraitsT >& str) + { + return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size())); + } + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template< typename OtherCharT, typename OtherTraitsT, typename OtherAllocatorT > + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type + operator<< (basic_formatting_ostream&& strm, std::basic_string< OtherCharT, OtherTraitsT, OtherAllocatorT > const& str) + { + return strm.formatted_write(str.c_str(), static_cast< std::streamsize >(str.size())); + } + + template< typename OtherCharT, typename OtherTraitsT > + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type + operator<< (basic_formatting_ostream&& strm, basic_string_literal< OtherCharT, OtherTraitsT > const& str) + { + return strm.formatted_write(str.c_str(), static_cast< std::streamsize >(str.size())); + } + + template< typename OtherCharT, typename OtherTraitsT > + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type + operator<< (basic_formatting_ostream&& strm, basic_string_ref< OtherCharT, OtherTraitsT > const& str) + { + return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size())); + } + + template< typename OtherCharT, typename OtherTraitsT, typename OtherAllocatorT > + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type + operator<< (basic_formatting_ostream&& strm, std::basic_string< OtherCharT, OtherTraitsT, OtherAllocatorT >& str) + { + return strm.formatted_write(str.c_str(), static_cast< std::streamsize >(str.size())); + } + + template< typename OtherCharT, typename OtherTraitsT > + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type + operator<< (basic_formatting_ostream&& strm, basic_string_literal< OtherCharT, OtherTraitsT >& str) + { + return strm.formatted_write(str.c_str(), static_cast< std::streamsize >(str.size())); + } + + template< typename OtherCharT, typename OtherTraitsT > + friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type + operator<< (basic_formatting_ostream&& strm, basic_string_ref< OtherCharT, OtherTraitsT >& str) + { + return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size())); + } +#endif + private: void init_stream() { @@ -703,17 +777,19 @@ void basic_formatting_ostream< CharT, TraitsT, AllocatorT >::aligned_write(const } } -template< typename CharT, typename TraitsT, typename AllocatorT, typename T > -inline basic_formatting_ostream< CharT, TraitsT, AllocatorT >& -operator<< (basic_formatting_ostream< CharT, TraitsT, AllocatorT >& strm, T const& value) +// Implementation note: these operators below should be the least attractive for the compiler +// so that user's overloads are chosen, when present. We use function template partial ordering for this purpose. +template< typename StreamT, typename T > +inline typename boost::log::aux::enable_if_formatting_ostream< StreamT, StreamT& >::type +operator<< (StreamT& strm, T const& value) { strm.stream() << value; return strm; } -template< typename CharT, typename TraitsT, typename AllocatorT, typename T > -inline basic_formatting_ostream< CharT, TraitsT, AllocatorT >& -operator<< (basic_formatting_ostream< CharT, TraitsT, AllocatorT >& strm, T& value) +template< typename StreamT, typename T > +inline typename boost::log::aux::enable_if_formatting_ostream< StreamT, StreamT& >::type +operator<< (StreamT& strm, T& value) { strm.stream() << value; return strm; @@ -721,19 +797,19 @@ operator<< (basic_formatting_ostream< CharT, TraitsT, AllocatorT >& strm, T& val #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) -template< typename CharT, typename TraitsT, typename AllocatorT, typename T > -inline basic_formatting_ostream< CharT, TraitsT, AllocatorT >& -operator<< (basic_formatting_ostream< CharT, TraitsT, AllocatorT >&& strm, T const& value) +template< typename StreamT, typename T > +inline typename boost::log::aux::enable_if_formatting_ostream< StreamT, StreamT& >::type +operator<< (StreamT&& strm, T const& value) { - static_cast< basic_formatting_ostream< CharT, TraitsT, AllocatorT >& >(strm) << value; + strm.stream() << value; return strm; } -template< typename CharT, typename TraitsT, typename AllocatorT, typename T > -inline basic_formatting_ostream< CharT, TraitsT, AllocatorT >& -operator<< (basic_formatting_ostream< CharT, TraitsT, AllocatorT >&& strm, T& value) +template< typename StreamT, typename T > +inline typename boost::log::aux::enable_if_formatting_ostream< StreamT, StreamT& >::type +operator<< (StreamT&& strm, T& value) { - static_cast< basic_formatting_ostream< CharT, TraitsT, AllocatorT >& >(strm) << value; + strm.stream() << value; return strm; } diff --git a/boost/log/utility/intrusive_ref_counter.hpp b/boost/log/utility/intrusive_ref_counter.hpp deleted file mode 100644 index 87f8ccc70b..0000000000 --- a/boost/log/utility/intrusive_ref_counter.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright Andrey Semashev 2007 - 2015. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -/*! - * \file intrusive_ref_counter.hpp - * \author Andrey Semashev - * \date 12.03.2009 - * - * This header is deprecated, use boost/smart_ptr/intrusive_ref_counter.hpp instead. The header is left for - * backward compatibility and will be removed in future versions. - */ - -#ifndef BOOST_LOG_UTILITY_INTRUSIVE_REF_COUNTER_HPP_INCLUDED_ -#define BOOST_LOG_UTILITY_INTRUSIVE_REF_COUNTER_HPP_INCLUDED_ - -#include <boost/smart_ptr/intrusive_ptr.hpp> -#include <boost/smart_ptr/intrusive_ref_counter.hpp> -#include <boost/log/detail/config.hpp> -#include <boost/log/detail/header.hpp> - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -#if defined(__GNUC__) -#pragma message "Boost.Log: This header is deprecated, use boost/smart_ptr/intrusive_ref_counter.hpp instead." -#elif defined(_MSC_VER) -#pragma message("Boost.Log: This header is deprecated, use boost/smart_ptr/intrusive_ref_counter.hpp instead.") -#endif - -namespace boost { - -BOOST_LOG_OPEN_NAMESPACE - -namespace aux { - -struct legacy_intrusive_ref_counter_root -{ - virtual ~legacy_intrusive_ref_counter_root() {} -}; - -} // namespace aux - -typedef boost::intrusive_ref_counter< aux::legacy_intrusive_ref_counter_root > intrusive_ref_counter; - -BOOST_LOG_CLOSE_NAMESPACE // namespace log - -} // namespace boost - -#include <boost/log/detail/footer.hpp> - -#endif // BOOST_LOG_UTILITY_INTRUSIVE_REF_COUNTER_HPP_INCLUDED_ diff --git a/boost/log/utility/manipulators/to_log.hpp b/boost/log/utility/manipulators/to_log.hpp index 20ea2c261d..9186616903 100644 --- a/boost/log/utility/manipulators/to_log.hpp +++ b/boost/log/utility/manipulators/to_log.hpp @@ -16,8 +16,9 @@ #define BOOST_LOG_UTILITY_MANIPULATORS_TO_LOG_HPP_INCLUDED_ #include <iosfwd> -#include <boost/mpl/bool.hpp> +#include <boost/core/enable_if.hpp> #include <boost/log/detail/config.hpp> +#include <boost/log/detail/is_ostream.hpp> #include <boost/log/utility/formatting_ostream_fwd.hpp> #include <boost/log/detail/header.hpp> @@ -46,34 +47,27 @@ private: value_type const& m_value; public: - explicit to_log_manip(value_type const& value) : m_value(value) {} - to_log_manip(to_log_manip const& that) : m_value(that.m_value) {} + explicit to_log_manip(value_type const& value) BOOST_NOEXCEPT : m_value(value) {} + to_log_manip(to_log_manip const& that) BOOST_NOEXCEPT : m_value(that.m_value) {} - value_type const& get() const { return m_value; } + value_type const& get() const BOOST_NOEXCEPT { return m_value; } }; -template< typename CharT, typename TraitsT, typename T, typename TagT > -inline std::basic_ostream< CharT, TraitsT >& operator<< (std::basic_ostream< CharT, TraitsT >& strm, to_log_manip< T, TagT > manip) -{ - strm << manip.get(); - return strm; -} - -template< typename CharT, typename TraitsT, typename AllocatorT, typename T, typename TagT > -inline basic_formatting_ostream< CharT, TraitsT, AllocatorT >& operator<< (basic_formatting_ostream< CharT, TraitsT, AllocatorT >& strm, to_log_manip< T, TagT > manip) +template< typename StreamT, typename T, typename TagT > +inline typename enable_if_c< log::aux::is_ostream< StreamT >::value, StreamT& >::type operator<< (StreamT& strm, to_log_manip< T, TagT > manip) { strm << manip.get(); return strm; } template< typename T > -inline to_log_manip< T > to_log(T const& value) +inline to_log_manip< T > to_log(T const& value) BOOST_NOEXCEPT { return to_log_manip< T >(value); } template< typename TagT, typename T > -inline to_log_manip< T, TagT > to_log(T const& value) +inline to_log_manip< T, TagT > to_log(T const& value) BOOST_NOEXCEPT { return to_log_manip< T, TagT >(value); } diff --git a/boost/log/utility/type_dispatch/date_time_types.hpp b/boost/log/utility/type_dispatch/date_time_types.hpp index 36c9265213..38e6a461f8 100644 --- a/boost/log/utility/type_dispatch/date_time_types.hpp +++ b/boost/log/utility/type_dispatch/date_time_types.hpp @@ -17,9 +17,7 @@ #include <ctime> #include <boost/mpl/vector.hpp> -#include <boost/mpl/copy.hpp> -#include <boost/mpl/back_inserter.hpp> -#include <boost/mpl/push_back.hpp> +#include <boost/preprocessor/seq/enum.hpp> #include <boost/date_time/gregorian/gregorian_types.hpp> #include <boost/date_time/local_time/local_time_types.hpp> #include <boost/date_time/posix_time/posix_time_types.hpp> @@ -34,29 +32,73 @@ namespace boost { BOOST_LOG_OPEN_NAMESPACE +//! Boost.Preprocessor sequence of the standard C date/time types +#define BOOST_LOG_NATIVE_DATE_TIME_TYPES()\ + (std::time_t)(std::tm) + +//! Boost.Preprocessor sequence of the standard C date types +#define BOOST_LOG_NATIVE_DATE_TYPES()\ + BOOST_LOG_NATIVE_DATE_TIME_TYPES() + +//! Boost.Preprocessor sequence of the Boost date/time types +#define BOOST_LOG_BOOST_DATE_TIME_TYPES()\ + (boost::posix_time::ptime)(boost::local_time::local_date_time) + +//! Boost.Preprocessor sequence of date/time types +#define BOOST_LOG_DATE_TIME_TYPES()\ + BOOST_LOG_NATIVE_DATE_TIME_TYPES()BOOST_LOG_BOOST_DATE_TIME_TYPES()\ + +//! Boost.Preprocessor sequence of the Boost date types +#define BOOST_LOG_BOOST_DATE_TYPES()\ + BOOST_LOG_BOOST_DATE_TIME_TYPES()(boost::gregorian::date) + +//! Boost.Preprocessor sequence of date types +#define BOOST_LOG_DATE_TYPES()\ + BOOST_LOG_NATIVE_DATE_TYPES()BOOST_LOG_BOOST_DATE_TYPES() + + +//! Boost.Preprocessor sequence of the standard time duration types +#define BOOST_LOG_NATIVE_TIME_DURATION_TYPES()\ + (double) /* result of difftime() */ + +//! Boost.Preprocessor sequence of the Boost time duration types +#define BOOST_LOG_BOOST_TIME_DURATION_TYPES()\ + (boost::posix_time::time_duration)(boost::gregorian::date_duration) + +//! Boost.Preprocessor sequence of time duration types +#define BOOST_LOG_TIME_DURATION_TYPES()\ + BOOST_LOG_NATIVE_TIME_DURATION_TYPES()BOOST_LOG_BOOST_TIME_DURATION_TYPES() + + +//! Boost.Preprocessor sequence of the Boost time period types +#define BOOST_LOG_BOOST_TIME_PERIOD_TYPES()\ + (boost::posix_time::time_period)(boost::local_time::local_time_period)(boost::gregorian::date_period) + +//! Boost.Preprocessor sequence of time period types +#define BOOST_LOG_TIME_PERIOD_TYPES()\ + BOOST_LOG_BOOST_TIME_PERIOD_TYPES() + + /*! * An MPL-sequence of natively supported date and time types of attributes */ typedef mpl::vector< - std::time_t, - std::tm + BOOST_PP_SEQ_ENUM(BOOST_LOG_NATIVE_DATE_TIME_TYPES()) > native_date_time_types; /*! * An MPL-sequence of Boost date and time types of attributes */ typedef mpl::vector< - posix_time::ptime, - local_time::local_date_time + BOOST_PP_SEQ_ENUM(BOOST_LOG_BOOST_DATE_TIME_TYPES()) > boost_date_time_types; /*! * An MPL-sequence with the complete list of the supported date and time types */ -typedef mpl::copy< - boost_date_time_types, - mpl::back_inserter< native_date_time_types > ->::type date_time_types; +typedef mpl::vector< + BOOST_PP_SEQ_ENUM(BOOST_LOG_DATE_TIME_TYPES()) +> date_time_types; /*! * An MPL-sequence of natively supported date types of attributes @@ -66,18 +108,16 @@ typedef native_date_time_types native_date_types; /*! * An MPL-sequence of Boost date types of attributes */ -typedef mpl::push_back< - boost_date_time_types, - gregorian::date ->::type boost_date_types; +typedef mpl::vector< + BOOST_PP_SEQ_ENUM(BOOST_LOG_BOOST_DATE_TYPES()) +> boost_date_types; /*! * An MPL-sequence with the complete list of the supported date types */ -typedef mpl::copy< - boost_date_types, - mpl::back_inserter< native_date_types > ->::type date_types; +typedef mpl::vector< + BOOST_PP_SEQ_ENUM(BOOST_LOG_DATE_TYPES()) +> date_types; /*! * An MPL-sequence of natively supported time types @@ -96,32 +136,28 @@ typedef date_time_types time_types; * An MPL-sequence of natively supported time duration types of attributes */ typedef mpl::vector< - double // result of difftime + BOOST_PP_SEQ_ENUM(BOOST_LOG_NATIVE_TIME_DURATION_TYPES()) > native_time_duration_types; /*! * An MPL-sequence of Boost time duration types of attributes */ typedef mpl::vector< - posix_time::time_duration, - gregorian::date_duration + BOOST_PP_SEQ_ENUM(BOOST_LOG_BOOST_TIME_DURATION_TYPES()) > boost_time_duration_types; /*! * An MPL-sequence with the complete list of the supported time duration types */ -typedef mpl::copy< - boost_time_duration_types, - mpl::back_inserter< native_time_duration_types > ->::type time_duration_types; +typedef mpl::vector< + BOOST_PP_SEQ_ENUM(BOOST_LOG_TIME_DURATION_TYPES()) +> time_duration_types; /*! * An MPL-sequence of Boost time duration types of attributes */ typedef mpl::vector< - posix_time::time_period, - local_time::local_time_period, - gregorian::date_period + BOOST_PP_SEQ_ENUM(BOOST_LOG_BOOST_TIME_PERIOD_TYPES()) > boost_time_period_types; /*! diff --git a/boost/log/utility/type_dispatch/dynamic_type_dispatcher.hpp b/boost/log/utility/type_dispatch/dynamic_type_dispatcher.hpp index 63c7bc1120..d01228a5da 100644 --- a/boost/log/utility/type_dispatch/dynamic_type_dispatcher.hpp +++ b/boost/log/utility/type_dispatch/dynamic_type_dispatcher.hpp @@ -19,11 +19,10 @@ #include <memory> #include <map> #include <boost/ref.hpp> +#include <boost/type_index.hpp> #include <boost/smart_ptr/shared_ptr.hpp> #include <boost/smart_ptr/make_shared_object.hpp> #include <boost/log/detail/config.hpp> -#include <boost/log/detail/visible_type.hpp> -#include <boost/log/utility/type_info_wrapper.hpp> #include <boost/log/utility/type_dispatch/type_dispatcher.hpp> #include <boost/log/detail/header.hpp> @@ -78,7 +77,7 @@ private: #endif // BOOST_LOG_DOXYGEN_PASS //! The dispatching map - typedef std::map< type_info_wrapper, shared_ptr< callback_base > > dispatching_map; + typedef std::map< typeindex::type_index, shared_ptr< callback_base > > dispatching_map; dispatching_map m_DispatchingMap; public: @@ -118,7 +117,7 @@ public: boost::shared_ptr< callback_base > p( boost::make_shared< callback_impl< T, VisitorT > >(boost::cref(visitor))); - type_info_wrapper wrapper(typeid(aux::visible_type< T >)); + typeindex::type_index wrapper(typeindex::type_id< T >()); m_DispatchingMap[wrapper].swap(p); } @@ -132,11 +131,10 @@ public: private: #ifndef BOOST_LOG_DOXYGEN_PASS - static callback_base get_callback(type_dispatcher* p, std::type_info const& type) + static callback_base get_callback(type_dispatcher* p, typeindex::type_index type) { dynamic_type_dispatcher* const self = static_cast< dynamic_type_dispatcher* >(p); - type_info_wrapper wrapper(type); - dispatching_map::iterator it = self->m_DispatchingMap.find(wrapper); + dispatching_map::iterator it = self->m_DispatchingMap.find(type); if (it != self->m_DispatchingMap.end()) return *it->second; else diff --git a/boost/log/utility/type_dispatch/standard_types.hpp b/boost/log/utility/type_dispatch/standard_types.hpp index a437f6f00a..fc01be34b4 100644 --- a/boost/log/utility/type_dispatch/standard_types.hpp +++ b/boost/log/utility/type_dispatch/standard_types.hpp @@ -17,8 +17,10 @@ #include <string> #include <boost/mpl/vector.hpp> -#include <boost/mpl/copy.hpp> -#include <boost/mpl/back_inserter.hpp> +#include <boost/mpl/vector/vector30.hpp> // needed to use mpl::vector sizes greater than 20 even when the default BOOST_MPL_LIMIT_VECTOR_SIZE is not set +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/seq/enum.hpp> +#include <boost/preprocessor/seq/size.hpp> #include <boost/log/detail/config.hpp> #include <boost/log/utility/string_literal_fwd.hpp> #include <boost/log/detail/header.hpp> @@ -31,70 +33,108 @@ namespace boost { BOOST_LOG_OPEN_NAMESPACE +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#define BOOST_LOG_AUX_STANDARD_TYPE_WCHAR_T() (wchar_t) +#else +#define BOOST_LOG_AUX_STANDARD_TYPE_WCHAR_T() +#endif + +#if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_LOG_NO_CXX11_CODECVT_FACETS) +#define BOOST_LOG_AUX_STANDARD_TYPE_CHAR16_T() (char16_t) +#else +#define BOOST_LOG_AUX_STANDARD_TYPE_CHAR16_T() +#endif + +#if !defined(BOOST_NO_CXX11_CHAR32_T) && !defined(BOOST_LOG_NO_CXX11_CODECVT_FACETS) +#define BOOST_LOG_AUX_STANDARD_TYPE_CHAR32_T() (char32_t) +#else +#define BOOST_LOG_AUX_STANDARD_TYPE_CHAR32_T() +#endif + +//! Boost.Preprocessor sequence of character types +#define BOOST_LOG_STANDARD_CHAR_TYPES()\ + (char)BOOST_LOG_AUX_STANDARD_TYPE_WCHAR_T()BOOST_LOG_AUX_STANDARD_TYPE_CHAR16_T()BOOST_LOG_AUX_STANDARD_TYPE_CHAR32_T() + +#if defined(BOOST_HAS_LONG_LONG) +#define BOOST_LOG_AUX_STANDARD_LONG_LONG_TYPES() (long long)(unsigned long long) +#else +#define BOOST_LOG_AUX_STANDARD_LONG_LONG_TYPES() +#endif + +//! Boost.Preprocessor sequence of integral types +#define BOOST_LOG_STANDARD_INTEGRAL_TYPES()\ + (bool)(signed char)(unsigned char)(short)(unsigned short)(int)(unsigned int)(long)(unsigned long)BOOST_LOG_AUX_STANDARD_LONG_LONG_TYPES()\ + BOOST_LOG_STANDARD_CHAR_TYPES() + +//! Boost.Preprocessor sequence of floating point types +#define BOOST_LOG_STANDARD_FLOATING_POINT_TYPES()\ + (float)(double)(long double) + +//! Boost.Preprocessor sequence of arithmetic types +#define BOOST_LOG_STANDARD_ARITHMETIC_TYPES()\ + BOOST_LOG_STANDARD_INTEGRAL_TYPES()BOOST_LOG_STANDARD_FLOATING_POINT_TYPES() + +#if defined(BOOST_LOG_USE_CHAR) +#define BOOST_LOG_AUX_STANDARD_STRING_TYPES() (std::string)(boost::log::string_literal) +#else +#define BOOST_LOG_AUX_STANDARD_STRING_TYPES() +#endif + +#if defined(BOOST_LOG_USE_WCHAR_T) +#define BOOST_LOG_AUX_STANDARD_WSTRING_TYPES() (std::wstring)(boost::log::wstring_literal) +#else +#define BOOST_LOG_AUX_STANDARD_WSTRING_TYPES() +#endif + +//! Boost.Preprocessor sequence of string types +#define BOOST_LOG_STANDARD_STRING_TYPES()\ + BOOST_LOG_AUX_STANDARD_STRING_TYPES()BOOST_LOG_AUX_STANDARD_WSTRING_TYPES() + +//! Boost.Preprocessor sequence of the default attribute value types supported by the library +#define BOOST_LOG_DEFAULT_ATTRIBUTE_VALUE_TYPES()\ + BOOST_LOG_STANDARD_ARITHMETIC_TYPES()BOOST_LOG_STANDARD_STRING_TYPES() + + /*! * An MPL-sequence of integral types of attributes, supported by default */ typedef mpl::vector< - bool, - char, -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - wchar_t, -#endif - signed char, - unsigned char, - short, - unsigned short, - int, - unsigned int, - long, - unsigned long -#if defined(BOOST_HAS_LONG_LONG) - , long long - , unsigned long long -#endif // defined(BOOST_HAS_LONG_LONG) + BOOST_PP_SEQ_ENUM(BOOST_LOG_STANDARD_INTEGRAL_TYPES()) > integral_types; /*! * An MPL-sequence of FP types of attributes, supported by default */ typedef mpl::vector< - float, - double, - long double + BOOST_PP_SEQ_ENUM(BOOST_LOG_STANDARD_FLOATING_POINT_TYPES()) > floating_point_types; /*! * An MPL-sequence of all numeric types of attributes, supported by default */ -typedef mpl::copy< - floating_point_types, - mpl::back_inserter< integral_types > ->::type numeric_types; +typedef mpl::vector< + BOOST_PP_SEQ_ENUM(BOOST_LOG_STANDARD_ARITHMETIC_TYPES()) +> arithmetic_types; + +//! Deprecated alias +typedef arithmetic_types numeric_types; /*! * An MPL-sequence of string types of attributes, supported by default */ typedef mpl::vector< -#ifdef BOOST_LOG_USE_CHAR - std::string, - string_literal -#ifdef BOOST_LOG_USE_WCHAR_T - , -#endif -#endif -#ifdef BOOST_LOG_USE_WCHAR_T - std::wstring, - wstring_literal -#endif + BOOST_PP_SEQ_ENUM(BOOST_LOG_STANDARD_STRING_TYPES()) > string_types; /*! * An MPL-sequence of all attribute value types that are supported by the library by default. */ -typedef mpl::copy< - string_types, - mpl::back_inserter< numeric_types > ->::type default_attribute_types; +typedef BOOST_PP_CAT(mpl::vector, BOOST_PP_SEQ_SIZE(BOOST_LOG_DEFAULT_ATTRIBUTE_VALUE_TYPES()))< + BOOST_PP_SEQ_ENUM(BOOST_LOG_DEFAULT_ATTRIBUTE_VALUE_TYPES()) +> default_attribute_value_types; + +//! Deprecated alias +typedef default_attribute_value_types default_attribute_types; BOOST_LOG_CLOSE_NAMESPACE // namespace log diff --git a/boost/log/utility/type_dispatch/static_type_dispatcher.hpp b/boost/log/utility/type_dispatch/static_type_dispatcher.hpp index a5743e28e0..bae420f7e5 100644 --- a/boost/log/utility/type_dispatch/static_type_dispatcher.hpp +++ b/boost/log/utility/type_dispatch/static_type_dispatcher.hpp @@ -21,6 +21,7 @@ #include <algorithm> #include <boost/array.hpp> #include <boost/static_assert.hpp> +#include <boost/type_index.hpp> #include <boost/mpl/if.hpp> #include <boost/mpl/size.hpp> #include <boost/mpl/begin.hpp> @@ -30,9 +31,7 @@ #include <boost/mpl/is_sequence.hpp> #include <boost/utility/addressof.hpp> #include <boost/log/detail/config.hpp> -#include <boost/log/detail/visible_type.hpp> #include <boost/log/utility/once_block.hpp> -#include <boost/log/utility/type_info_wrapper.hpp> #include <boost/log/utility/type_dispatch/type_dispatcher.hpp> #include <boost/log/detail/header.hpp> @@ -50,7 +49,7 @@ namespace aux { struct dispatching_map_order { typedef bool result_type; - typedef std::pair< type_info_wrapper, void* > first_argument_type, second_argument_type; + typedef std::pair< typeindex::type_index, void* > first_argument_type, second_argument_type; result_type operator() (first_argument_type const& left, second_argument_type const& right) const { return (left.first < right.first); @@ -62,15 +61,15 @@ template< typename VisitorT > struct dispatching_map_initializer { template< typename IteratorT > - static BOOST_FORCEINLINE void init(IteratorT*, IteratorT*, std::pair< type_info_wrapper, void* >*) + static BOOST_FORCEINLINE void init(IteratorT*, IteratorT*, std::pair< typeindex::type_index, void* >*) { } template< typename BeginIteratorT, typename EndIteratorT > - static BOOST_FORCEINLINE void init(BeginIteratorT*, EndIteratorT* end, std::pair< type_info_wrapper, void* >* p) + static BOOST_FORCEINLINE void init(BeginIteratorT*, EndIteratorT* end, std::pair< typeindex::type_index, void* >* p) { typedef typename mpl::deref< BeginIteratorT >::type type; - do_init(static_cast< visible_type< type >* >(0), p); + do_init(static_cast< type* >(0), p); typedef typename mpl::next< BeginIteratorT >::type next_iterator_type; init(static_cast< next_iterator_type* >(0), end, p + 1); @@ -78,9 +77,9 @@ struct dispatching_map_initializer private: template< typename T > - static BOOST_FORCEINLINE void do_init(visible_type< T >*, std::pair< type_info_wrapper, void* >* p) + static BOOST_FORCEINLINE void do_init(T*, std::pair< typeindex::type_index, void* >* p) { - p->first = typeid(visible_type< T >); + p->first = typeindex::type_id< T >(); typedef void (*trampoline_t)(void*, T const&); BOOST_STATIC_ASSERT_MSG(sizeof(trampoline_t) == sizeof(void*), "Boost.Log: Unsupported platform, the size of a function pointer differs from the size of a pointer"); @@ -101,7 +100,7 @@ class type_sequence_dispatcher_base : { private: //! Dispatching map element type - typedef std::pair< type_info_wrapper, void* > dispatching_map_element_type; + typedef std::pair< typeindex::type_index, void* > dispatching_map_element_type; private: //! Dispatching map @@ -123,21 +122,20 @@ protected: private: //! The get_callback method implementation - static callback_base get_callback(type_dispatcher* p, std::type_info const& type) + static callback_base get_callback(type_dispatcher* p, typeindex::type_index type) { type_sequence_dispatcher_base* const self = static_cast< type_sequence_dispatcher_base* >(p); - type_info_wrapper wrapper(type); const dispatching_map_element_type* begin = self->m_dispatching_map_begin; const dispatching_map_element_type* end = begin + self->m_dispatching_map_size; const dispatching_map_element_type* it = std::lower_bound ( begin, end, - dispatching_map_element_type(wrapper, (void*)0), + dispatching_map_element_type(type, (void*)0), dispatching_map_order() ); - if (it != end && it->first == wrapper) + if (it != end && it->first == type) return callback_base(self->m_visitor, it->second); else return callback_base(); @@ -160,7 +158,7 @@ public: private: //! The dispatching map typedef array< - std::pair< type_info_wrapper, void* >, + std::pair< typeindex::type_index, void* >, mpl::size< supported_types >::value > dispatching_map; @@ -210,13 +208,13 @@ class single_type_dispatcher_base : { private: //! The type to match against - std::type_info const& m_type; + typeindex::type_index m_type; //! A callback for the supported type callback_base m_callback; protected: //! Initializing constructor - single_type_dispatcher_base(std::type_info const& type, callback_base const& callback) BOOST_NOEXCEPT : + single_type_dispatcher_base(typeindex::type_index type, callback_base const& callback) BOOST_NOEXCEPT : type_dispatcher(&single_type_dispatcher_base::get_callback), m_type(type), m_callback(callback) @@ -225,7 +223,7 @@ protected: private: //! The get_callback method implementation - static callback_base get_callback(type_dispatcher* p, std::type_info const& type) + static callback_base get_callback(type_dispatcher* p, typeindex::type_index type) { single_type_dispatcher_base* const self = static_cast< single_type_dispatcher_base* >(p); if (type == self->m_type) @@ -248,7 +246,7 @@ public: //! Constructor template< typename VisitorT > explicit single_type_dispatcher(VisitorT& visitor) BOOST_NOEXCEPT : - single_type_dispatcher_base(typeid(visible_type< T >), callback_base((void*)boost::addressof(visitor), &callback_base::trampoline< VisitorT, T >)) + single_type_dispatcher_base(typeindex::type_id< T >(), callback_base((void*)boost::addressof(visitor), &callback_base::trampoline< VisitorT, T >)) { } diff --git a/boost/log/utility/type_dispatch/type_dispatcher.hpp b/boost/log/utility/type_dispatch/type_dispatcher.hpp index 9ca52cd56c..c5265113fc 100644 --- a/boost/log/utility/type_dispatch/type_dispatcher.hpp +++ b/boost/log/utility/type_dispatch/type_dispatcher.hpp @@ -15,10 +15,9 @@ #ifndef BOOST_LOG_TYPE_DISPATCHER_HPP_INCLUDED_ #define BOOST_LOG_TYPE_DISPATCHER_HPP_INCLUDED_ -#include <typeinfo> +#include <boost/type_index.hpp> #include <boost/static_assert.hpp> #include <boost/log/detail/config.hpp> -#include <boost/log/detail/visible_type.hpp> #include <boost/utility/explicit_operator_bool.hpp> #include <boost/log/detail/header.hpp> @@ -148,7 +147,7 @@ public: protected: //! Pointer to the callback acquisition method - typedef callback_base (*get_callback_impl_type)(type_dispatcher*, std::type_info const&); + typedef callback_base (*get_callback_impl_type)(type_dispatcher*, typeindex::type_index); private: //! Pointer to the callback acquisition method @@ -176,7 +175,7 @@ public: template< typename T > callback< T > get_callback() { - return callback< T >((this->m_get_callback_impl)(this, typeid(boost::log::aux::visible_type< T >))); + return callback< T >((this->m_get_callback_impl)(this, typeindex::type_id< T >())); } }; diff --git a/boost/log/utility/type_info_wrapper.hpp b/boost/log/utility/type_info_wrapper.hpp index 9b1dc53201..81cd3aed69 100644 --- a/boost/log/utility/type_info_wrapper.hpp +++ b/boost/log/utility/type_info_wrapper.hpp @@ -26,6 +26,12 @@ #pragma once #endif +#if defined(__GNUC__) +#pragma message "Boost.Log: This header is deprecated, use Boost.TypeIndex instead." +#elif defined(_MSC_VER) +#pragma message("Boost.Log: This header is deprecated, use Boost.TypeIndex instead.") +#endif + namespace boost { BOOST_LOG_OPEN_NAMESPACE |