This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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: [libstdc++-v3][C++14] Implement N3654 - Quoted Strings


On 06/05/2013 04:01 PM, Jonathan Wakely wrote:
On 5 June 2013 20:18, Ed Smith-Rowland wrote:
Greetings,
This patch implements quoted string manipulators for C++14.

27.7.6 - Quoted manipulators        [quoted.manip].

The idea is to allow round trip insert and extract of strings with spaces.

   std::stringstream ss;
   std::string original = "thing1  thing1";
   std::string round_trip;
   ss << std::quoted(original);
   ss >> std::quoted(round_trip);
   assert( original == round_trip );

Builds and tests clean on x86-64-linux.
As I suggested for your literals patch, couldn't the test for:
#if __cplusplus > 201103L
go inside the existing one?

i.e.

#if __cplusplus >= 201103L
[...]
#if __cplusplus > 201103L
[...]
#endif
#endif
Certainly. I forgot that in the last literals patch. I'll fix that after I finish this one. (I just noticed junk comments in the testcases for literals also).


_Quoted_string appears to do two copies of the string, one for the
constructor argument and one for the member variable, do they
definitely get elided?
I looks that way. But all used of the template parm String are either references or pointers so these operations should be efficient.
_Quoted_string should be used as a non-owning string thing.

The members of _Quoted_string should be named _M_xxx not __xxx, to
follow the coding style guidelines.
Done.

What is __delim2 for?

What if the first extraction in the operator>> fails, is doing
__is.unget() the right thing to do?
Thanks. I'll return with __is rather than attempting to continue reading.

You could simplify the quoted() overloads by using auto return type
deduction, is it an intentional choice not to use that?
For some reason I forgot about auto return type in C++14. It sure cleans things up nicely. Done.
Rebuilt and retested on x86_64

Attachment: CL_quoted
Description: Text document

Attachment: patch_quoted2
Description: Text document


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