This is the mail archive of the
mailing list for the GCC project.
Re: std::quoted doesn't respect padding
- From: Ed Smith-Rowland <3dw4rd at verizon dot net>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: Jonathan Wakely <jwakely dot gcc at gmail dot com>, libstdc++ <libstdc++ at gcc dot gnu dot org>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 06 Jun 2014 10:08:11 -0400
- Subject: Re: std::quoted doesn't respect padding
- Authentication-results: sourceware.org; auth=none
- References: <CAH6eHdR5tfJuyqL24Dfmu=41e5_7fZLhsgxMqBdhgE4wONW8Xw at mail dot gmail dot com> <531F2937 dot 7020106 at verizon dot net> <20140401113329 dot GL13192 at redhat dot com> <53909026 dot 8020305 at verizon dot net> <20140605154832 dot GE31471 at redhat dot com>
On 06/05/2014 11:48 AM, Jonathan Wakely wrote:
On 05/06/14 11:43 -0400, Ed Smith-Rowland wrote:
On 04/01/2014 07:33 AM, Jonathan Wakely wrote:
On 11/03/14 11:18 -0400, Ed Smith-Rowland wrote:
On 02/14/2014 07:56 PM, Jonathan Wakely wrote:
We need to implement this fix (probably after 4.9 is released though)
Here is a patch (Stage 1 obviously).
A couple of things I didn't notice earlier ...
--- include/std/iomanip (revision 208430)
+++ include/std/iomanip (working copy)
@@ -41,6 +41,7 @@
#if __cplusplus >= 201103L
+#include <sstream> // used in quoted.
We really only need <sstream> for __cplusplus > 201103L, otherwise we
include it unnecessarily for C++11.
- return __os;
+ return __os << __ostr.str();
It should be slightly more efficient to do __os << __ostr.rdbuf() here,
and in the other operator<< overload, since that copies directly from
the stringbuf to __os's own streambuf, rather than creating a
temporary std::string and copying from that.
Sorry for the hiatus...
Here is a new patch with issues fixed.
OK if it passes testing on x86_64-linux?
Great, OK for trunk and 4.9 too, I think.
The rdbuf version fails.
The compare asserts fail and
// Should be: ["AB \"CD\" EF"xxxxxx]
// Gives : ["AB \"CD\" EF"xxxxxx]
std::cout << "[" << std::left << std::setfill('x') << std::setw(20)
<< R"("AB \"CD\" EF")" << "]" << std::endl;
// Should be: ["GH \"IJ\" KL"yyyyyy]
// Gives : ["yyyyyyyyyyyyyyyyyyyGH \"IJ\" KL"]
std::cout << "[" << std::left << std::setfill('y') << std::setw(20)
<< std::quoted(R"(GH "IJ" KL)") << "]" << std::endl;
["AB \"CD\" EF"xxxxxx]
No newline on the second line - just the '['.
I'll look at rdbuf. Error in rdbuf? Do I need to do something?
Failing that we know str() works even though it is inefficient.