Blame SOURCES/boost-1.59.0-log.patch

549713
From 7da193fde1a9c1bc925ee980339f4df2e1a66fa7 Mon Sep 17 00:00:00 2001
549713
From: Andrey Semashev <andrey.semashev@gmail.com>
549713
Date: Sun, 23 Aug 2015 17:27:20 +0300
549713
Subject: [PATCH] Fixed compilation of operator<< into a record ostream, when
549713
 the operator right hand argument is not directly supported by
549713
 formatting_ostream. Fixed #11549.
549713
549713
---
549713
549713
diff --git a/include/boost/log/sources/record_ostream.hpp b/include/boost/log/sources/record_ostream.hpp
549713
index b3c58e2..c1e8059 100644
549713
--- a/include/boost/log/sources/record_ostream.hpp
549713
+++ b/include/boost/log/sources/record_ostream.hpp
549713
@@ -39,6 +39,18 @@ namespace boost {
549713
 
549713
 BOOST_LOG_OPEN_NAMESPACE
549713
 
549713
+template< typename CharT >
549713
+class basic_record_ostream;
549713
+
549713
+namespace aux {
549713
+
549713
+template< typename StreamT, typename R >
549713
+struct enable_if_record_ostream {};
549713
+template< typename CharT, typename R >
549713
+struct enable_if_record_ostream< basic_record_ostream< CharT >, R > { typedef R type; };
549713
+
549713
+} // namespace aux
549713
+
549713
 /*!
549713
  * \brief Logging record adapter with a streaming capability
549713
  *
549713
@@ -174,6 +186,55 @@ typedef basic_record_ostream< char > record_ostream;        //!< Convenience typ
549713
 typedef basic_record_ostream< wchar_t > wrecord_ostream;    //!< Convenience typedef for wide-character logging
549713
 #endif
549713
 
549713
+// Implementation note: these operators below should be the least attractive for the compiler
549713
+// so that user's overloads are chosen, when present. We use function template partial ordering for this purpose.
549713
+// We also don't use perfect forwarding for the right hand argument because in ths case the generic overload
549713
+// would be more preferred than the typical one written by users:
549713
+//
549713
+// record_ostream& operator<< (record_ostream& strm, my_type const& arg);
549713
+//
549713
+// This is because my_type rvalues require adding const to the type, which counts as a conversion that is not required
549713
+// if there is a perfect forwarding overload.
549713
+template< typename StreamT, typename T >
549713
+inline typename boost::log::aux::enable_if_record_ostream< StreamT, StreamT& >::type
549713
+operator<< (StreamT& strm, T const& value)
549713
+{
549713
+    typedef basic_formatting_ostream< typename StreamT::char_type > formatting_ostream_type;
549713
+    static_cast< formatting_ostream_type& >(strm) << value;
549713
+    return strm;
549713
+}
549713
+
549713
+template< typename StreamT, typename T >
549713
+inline typename boost::log::aux::enable_if_record_ostream< StreamT, StreamT& >::type
549713
+operator<< (StreamT& strm, T& value)
549713
+{
549713
+    typedef basic_formatting_ostream< typename StreamT::char_type > formatting_ostream_type;
549713
+    static_cast< formatting_ostream_type& >(strm) << value;
549713
+    return strm;
549713
+}
549713
+
549713
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
549713
+
549713
+template< typename StreamT, typename T >
549713
+inline typename boost::log::aux::enable_if_record_ostream< StreamT, StreamT& >::type
549713
+operator<< (StreamT&& strm, T const& value)
549713
+{
549713
+    typedef basic_formatting_ostream< typename StreamT::char_type > formatting_ostream_type;
549713
+    static_cast< formatting_ostream_type& >(strm) << value;
549713
+    return strm;
549713
+}
549713
+
549713
+template< typename StreamT, typename T >
549713
+inline typename boost::log::aux::enable_if_record_ostream< StreamT, StreamT& >::type
549713
+operator<< (StreamT&& strm, T& value)
549713
+{
549713
+    typedef basic_formatting_ostream< typename StreamT::char_type > formatting_ostream_type;
549713
+    static_cast< formatting_ostream_type& >(strm) << value;
549713
+    return strm;
549713
+}
549713
+
549713
+#endif // !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
549713
+
549713
 namespace aux {
549713
 
549713
 //! Internal class that provides formatting streams for record pumps
549713
diff --git a/include/boost/log/utility/formatting_ostream.hpp b/include/boost/log/utility/formatting_ostream.hpp
549713
index 4345206..744acc0 100644
549713
--- a/include/boost/log/utility/formatting_ostream.hpp
549713
+++ b/include/boost/log/utility/formatting_ostream.hpp
549713
@@ -779,6 +779,13 @@ void basic_formatting_ostream< CharT, TraitsT, AllocatorT >::aligned_write(const
549713
 
549713
 // Implementation note: these operators below should be the least attractive for the compiler
549713
 // so that user's overloads are chosen, when present. We use function template partial ordering for this purpose.
549713
+// We also don't use perfect forwarding for the right hand argument because in ths case the generic overload
549713
+// would be more preferred than the typical one written by users:
549713
+//
549713
+// formatting_ostream& operator<< (formatting_ostream& strm, my_type const& arg);
549713
+//
549713
+// This is because my_type rvalues require adding const to the type, which counts as a conversion that is not required
549713
+// if there is a perfect forwarding overload.
549713
 template< typename StreamT, typename T >
549713
 inline typename boost::log::aux::enable_if_formatting_ostream< StreamT, StreamT& >::type
549713
 operator<< (StreamT& strm, T const& value)