summaryrefslogtreecommitdiff
path: root/boost/log/utility
diff options
context:
space:
mode:
Diffstat (limited to 'boost/log/utility')
-rw-r--r--boost/log/utility/empty_deleter.hpp42
-rw-r--r--boost/log/utility/explicit_operator_bool.hpp42
-rw-r--r--boost/log/utility/formatting_ostream.hpp126
-rw-r--r--boost/log/utility/intrusive_ref_counter.hpp55
-rw-r--r--boost/log/utility/manipulators/to_log.hpp24
-rw-r--r--boost/log/utility/type_dispatch/date_time_types.hpp94
-rw-r--r--boost/log/utility/type_dispatch/dynamic_type_dispatcher.hpp12
-rw-r--r--boost/log/utility/type_dispatch/standard_types.hpp122
-rw-r--r--boost/log/utility/type_dispatch/static_type_dispatcher.hpp34
-rw-r--r--boost/log/utility/type_dispatch/type_dispatcher.hpp7
-rw-r--r--boost/log/utility/type_info_wrapper.hpp6
11 files changed, 286 insertions, 278 deletions
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