This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] std::experimental::ostream_joiner


On 02/05/15 19:34 +0200, Daniel Krügler wrote:
2015-05-02 19:14 GMT+02:00 Jonathan Wakely <jwakely@redhat.com>:
The last piece of the Library Fundamentals 2 TS (until next week when
all of v1 gets voted into v2, when it will include the v1 stuff we're
missing).

Tested powerpc64le-linux, committed to trunk.

Do you really want to copy the ugliness of the Standard specification
for in-class members or could this be made more readable as follows
(affects four members):

ostream_joiner<_DelimT, _CharT, _Traits>&
=>
ostream_joiner&

? [I'm asking because I have not seen this to be the general style
used in libstdc++]

Good point, I should probably stop working now, I've already spent my
whole Saturday and I'm clearly not paying attention properly!

The TS should be fixed to use the injected-class-name too:
https://github.com/cplusplus/fundamentals-ts/pull/56

Fixed by this patch, tested powerpc64le-linux and committed to trunk.
commit af7ef923b9b95f5c7c59e6706095fba460a23a81
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Sat May 2 19:00:16 2015 +0100

    	* include/experimental/iterator (ostream_joiner): Simplify by using
    	the injected-class-name and the ostream_type typedef.

diff --git a/libstdc++-v3/include/experimental/iterator b/libstdc++-v3/include/experimental/iterator
index 027043a..9a38f6b 100644
--- a/libstdc++-v3/include/experimental/iterator
+++ b/libstdc++-v3/include/experimental/iterator
@@ -80,7 +80,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { }
 
     template<typename _Tp>
-      ostream_joiner<_DelimT, _CharT, _Traits>&
+      ostream_joiner&
       operator=(const _Tp& __value)
       {
 	if (!_M_first)
@@ -90,20 +90,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *this;
       }
 
-    ostream_joiner<_DelimT, _CharT, _Traits>&
-    operator*() noexcept
-    { return *this; }
-
-    ostream_joiner<_DelimT, _CharT, _Traits>&
-    operator++() noexcept
-    { return *this; }
-
-    ostream_joiner<_DelimT, _CharT, _Traits>&
-    operator++(int) noexcept
-    { return *this; }
+    ostream_joiner& operator*() noexcept { return *this; }
+    ostream_joiner& operator++() noexcept { return *this; }
+    ostream_joiner& operator++(int) noexcept { return *this; }
 
   private:
-    basic_ostream<_CharT, _Traits>* _M_out;
+    ostream_type* _M_out;
     _DelimT _M_delim;
     bool _M_first = true;
   };
@@ -113,9 +105,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     inline ostream_joiner<decay_t<_DelimT>, _CharT, _Traits>
     make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os,
 			_DelimT&& __delimiter)
-    {
-      return { __os, std::forward<_DelimT>(__delimiter) };
-    }
+    { return { __os, std::forward<_DelimT>(__delimiter) }; }
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace fundamentals_v2

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]