Topic: string_view and the quoted manipulator
Author: 3dw4rd@verizon.net
Date: Thu, 7 Nov 2013 10:33:14 -0800 (PST)
Raw View
------=_Part_1436_6642548.1383849194755
Content-Type: text/plain; charset=ISO-8859-1
I discovered that a string_view implementation can't use std::quoted (n3654<http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3654.html>)
because the template functions explicitly only take const CharT* and
basic_strings (const for inserter use and nonconst for extractor use):
template <class charT>
*T11* quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\'));
template <class charT, class traits, class Allocator>
*T12* quoted(const basic_string<charT, traits, Allocator>& s,
charT delim=charT('"'), charT escape=charT('\\'));
template <class charT, class traits, class Allocator>
*T13* quoted(basic_string<charT, traits, Allocator>& s,
charT delim=charT('"'), charT escape=charT('\\'));
I think we should put this on the list of things to make sure string_view
plays well with in the rest of the library (I know string_view proposal is
now self-contained).
My question is how to add this?
1. Make each new string-like class add a quoted manipulator overload?
2. Add a generic quoted manipulator like this:
// Try a more generic quoted manipulator.
template<typename _String, typename _CharT = typename _String::value_type>
inline auto
quoted(const _String& __string,
_CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
{
return __detail::_Quoted_string<const _String&, _CharT>
(__string, __delim, __escape);
}
This is a const string inserter version suitable for string_view. We
probably don't want a generic extractor version.
The only requirement that I can see is a typedef value_type.
Food for thought.
Ed
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_1436_6642548.1383849194755
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I discovered that a string_view implementation can't use s=
td::quoted (<a href=3D"http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2=
013/n3654.html">n3654</a>) because the template functions explicitly only t=
ake const CharT* and basic_strings (const for inserter use and nonconst for=
extractor use):<br><br><div class=3D"prettyprint" style=3D"background-colo=
r: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: soli=
d; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><=
div class=3D"subprettyprint"><pre><ins><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> charT</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
></span></ins><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br> </span><ins><i><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">T11</span></i><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> quoted</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">const<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> charT</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> s</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> charT delim</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">charT</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">'"'</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">),</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
charT escape</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">char=
T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #080;" class=3D"styled-by-prettify">'\\'</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">));</span></ins><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><ins><span=
style=3D"color: #008;" class=3D"styled-by-prettify">template</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> charT</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> traits</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #606;" class=3D"styled-by-prettify">Allocator</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">></span></ins><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br> </span><ins><i><span =
style=3D"color: #000;" class=3D"styled-by-prettify">T12</span></i><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> quoted</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> basic_string</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">charT</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> traits</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Alloc=
ator</span><span style=3D"color: #660;" class=3D"styled-by-prettify">>&a=
mp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> s</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span></ins><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
</span><ins><span style=3D"color: #000;" =
class=3D"styled-by-prettify">charT delim</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">charT</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #080;" class=3D"styled-by-=
prettify">'"'</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> char=
T escape</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">charT</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #080;" class=3D"styled-by-prettify">'\\'</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">));</span></ins><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><ins><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> charT</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> traits</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">Allocator</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">></span></ins><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br> </span><ins><i><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">T13</span></i><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> quoted</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">basic_string</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">charT</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> traits</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Allo=
cator</span><span style=3D"color: #660;" class=3D"styled-by-prettify">>&=
amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> s</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span></ins>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
</span><ins><span style=3D"color: #000;"=
class=3D"styled-by-prettify">charT delim</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">charT</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #080;" class=3D"styled-by-=
prettify">'"'</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> char=
T escape</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">charT</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #080;" class=3D"styled-by-prettify">'\\'</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">));</span></ins></pre></div=
></code></div><br>I think we should put this on the list of things to make =
sure string_view plays well with in the rest of the library (I know string_=
view proposal is now self-contained).<br><br>My question is how to add this=
?<br>1. Make each new string-like class add a quoted manipulator overload?<=
br>2. Add a generic quoted manipulator like this:<br><div class=3D"prettypr=
int" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, =
187, 187); border-style: solid; border-width: 1px; word-wrap: break-word;">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// Try a more generic quoted ma=
nipulator.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>template</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typenam=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> _String<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> _CharT </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> _String</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">value_type</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">inline</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br> quoted</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">const</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> _String</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> __st=
ring</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nbs=
p; _CharT __delim </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> _CharT</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #080;" class=3D"styled-by-prettify=
">'"'</span><span style=3D"color: #660;" class=3D"styled-by-prettify">),</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> _CharT __esc=
ape </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> _CharT</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #080;" class=3D"styled-by-prettify">'\\'</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">))</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br> </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> __detail</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">_Quoted_stri</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">ng</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify"><</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> _String</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> _CharT</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">__string</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> __delim</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> __escape</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br><br></span></div></code></div><br>This is a const s=
tring inserter version suitable for string_view. We probably don't wa=
nt a generic extractor version.<br>The only requirement that I can see is a=
typedef value_type.<br><br>Food for thought.<br><br>Ed<br><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1436_6642548.1383849194755--
.