Topic: Allowing string literals to match `char...` packs in templates
Author: Vittorio Romeo <vittorio.romeo.vee@gmail.com>
Date: Wed, 16 Nov 2016 06:04:32 -0800 (PST)
Raw View
------=_Part_2579_485815145.1479305072521
Content-Type: multipart/alternative;
boundary="----=_Part_2580_1140857293.1479305072521"
------=_Part_2580_1140857293.1479305072521
Content-Type: text/plain; charset=UTF-8
Currently string literals are not allowed as template arguments because the
standard explicitly prevents that
*(see 14.3.2 Template non-type arguments)....why?A possible issue arises
when passing the same literal twice - consider this case:template<const
char* TS> struct t{}; int main() { t<"hi"> a{}; t<"hi"> b{}; } // Issue:
does `TS` have the same address for `a` and `b`?*
*The problem seems to be that, since string literals really are
pointers/references, there's no sensible way of dealing with them as
compile-time template parameters.But it would be really useful to have such
a feature:template<magic TS> struct tag{}; int main() {
database::table<tag<"user">, database::field<tag<"name">, std::string>,
database::field<tag<"age">, int> > db_user;
db_user.get<tag<"name">>(id(10)); db_user.get<tag<"age">>(id(10)); }*
*Another example:template <typename F, std::size_t ... I> constexpr auto
string_builder(F f, std::index_sequence<I...>) { return
char_sequence<f(I)...>{}; } template<magic TS> auto tag(TS s) { return
string_builder([]() constexpr { return s; }, magic_sizeof(s)); } int main()
{ static_assert(is_same(decltype(tag("hi")), decltype(tag("hi"))));
static_assert(!is_same(decltype(tag("hi")), decltype(tag("bye")))); }*
The above examples show the definition of unique types based on strings in-situ
without using macros. (It is already possible with macros
<https://github.com/irrequietus/typestring>.)
The problem is that there currently is nothing in the language that could
be used as "*magic*".
Therefore I propose that, to avoid ambiguity, magic should simply be a
char... pack.
*A **special rule would be added to the standard that allows string
literals to be matched into char... packs as template parameters.*
template<typename> struct t_typename{};template<const char*> struct t_constchar{};template<const char(&)[3]> struct t_charref{};template<char...> struct t_chars{};template<auto> struct t_auto{};template<auto...> struct t_autos{};
int main()
{
t_typename<"hi">{}; // still would FAIL to compile, as intended
t_constchar<"hi">{}; // still would FAIL to compile, as intended
t_charref<"hi">{}; // still would FAIL to compile, as intended
t_chars<"hi">{}; // *should COMPILE with the proposed changes*
t_auto<"hi">{}; // still would FAIL to compile, as intended
t_autos<"hi">{}; // *should COMPILE with the proposed changes*
}
Using char... instead of pointers/reference would make the literal behave
just a sequence of compile-time characters.
What do you think?
The same problem is addressed by P0424R0
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0424r0.pdf>, but
only for user-defined literals.
I think that allowing string literals to be matched into template char... argument
packs would make sense, because the programmer only cares about the
literal's "characters" *(not its address) *at compile-time.
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/9de07b5f-f870-4a02-882f-54f9fdd12ffd%40isocpp.org.
------=_Part_2580_1140857293.1479305072521
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><span style=3D"color: rgb(51, 51, 51); font-family: -apple=
-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-s=
erif, "Apple Color Emoji", "Segoe UI Emoji", "Sego=
e UI Symbol"; font-size: 16px;">Currently string literals are not allo=
wed as template arguments because the standard explicitly prevents that=C2=
=A0</span><em style=3D"box-sizing: border-box; color: rgb(51, 51, 51); font=
-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica=
, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji&qu=
ot;, "Segoe UI Symbol"; font-size: 16px;">(see 14.3.2 Template no=
n-type arguments).<br><br>...why?<br><span style=3D"font-style: normal;">A =
possible issue arises when passing the same literal twice - consider this c=
ase:<br></span><pre style=3D"box-sizing: border-box; font-family: Consolas,=
"Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px;=
font-style: normal; font-stretch: normal; line-height: 1.45; word-wrap: no=
rmal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); =
border-radius: 3px; word-break: normal;"><span class=3D"pl-k" style=3D"box-=
sizing: border-box; color: rgb(167, 29, 93);">template</span><<span clas=
s=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 93);">const=
</span> <span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(16=
7, 29, 93);">char</span>* TS> <span class=3D"pl-k" style=3D"box-sizing: =
border-box; color: rgb(167, 29, 93);">struct</span> <span class=3D"pl-en" s=
tyle=3D"box-sizing: border-box; color: rgb(121, 93, 163);">t</span>{};
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">int</span> <span class=3D"pl-en" style=3D"box-sizing: border-box; colo=
r: rgb(121, 93, 163);">main</span>()
{
t<<span class=3D"pl-s" style=3D"box-sizing: border-box; color: rgb(2=
4, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-box;">&quo=
t;</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;">"<=
/span></span>> a{};
t<<span class=3D"pl-s" style=3D"box-sizing: border-box; color: rgb(2=
4, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-box;">&quo=
t;</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;">"<=
/span></span>> b{};
}
<pre style=3D"box-sizing: border-box; font-family: Consolas, "Liberati=
on Mono", Menlo, Courier, monospace; font-size: 13.6px; font-stretch: =
normal; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto=
; border-radius: 3px; word-break: normal;"><span class=3D"pl-c" style=3D"bo=
x-sizing: border-box; color: rgb(150, 152, 150);">// Issue: does `TS` have =
the same address for `a` and `b`?</span></pre></pre><br></em><div><em style=
=3D"box-sizing: border-box; color: rgb(51, 51, 51); font-family: -apple-sys=
tem, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif=
, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI=
Symbol"; font-size: 16px;"><p style=3D"box-sizing: border-box; font-s=
tyle: normal;">The problem seems to be that, since string literals really a=
re pointers/references, there's no sensible way of dealing with them as=
compile-time template parameters.</p><p style=3D"box-sizing: border-box; f=
ont-style: normal;">But it would be really useful to have such a feature:<b=
r><br></p><pre style=3D"box-sizing: border-box; font-family: Consolas, &quo=
t;Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; font=
-style: normal; font-stretch: normal; line-height: 1.45; word-wrap: normal;=
padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); borde=
r-radius: 3px; word-break: normal;"><span class=3D"pl-k" style=3D"box-sizin=
g: border-box; color: rgb(167, 29, 93);">template</span><<b><u>magic</u>=
</b>TS> <span class=3D"pl-k" style=3D"box-sizing: border-box; color: rg=
b(167, 29, 93);">struct</span> <span class=3D"pl-en" style=3D"box-sizing: b=
order-box; color: rgb(121, 93, 163);">tag</span>{};
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">int</span> <span class=3D"pl-en" style=3D"box-sizing: border-box; colo=
r: rgb(121, 93, 163);">main</span>()
{
database::table<tag<<span class=3D"pl-s" style=3D"box-sizing: bor=
der-box; color: rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizi=
ng: border-box;">"</span>user<span class=3D"pl-pds" style=3D"box-sizin=
g: border-box;">"</span></span>>,
database::field<tag<<span class=3D"pl-s" style=3D"box-sizing:=
border-box; color: rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-=
sizing: border-box;">"</span>name<span class=3D"pl-pds" style=3D"box-s=
izing: border-box;">"</span></span>>, std::string>,
database::field<tag<<span class=3D"pl-s" style=3D"box-sizing:=
border-box; color: rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-=
sizing: border-box;">"</span>age<span class=3D"pl-pds" style=3D"box-si=
zing: border-box;">"</span></span>>, <span class=3D"pl-k" style=3D"=
box-sizing: border-box; color: rgb(167, 29, 93);">int</span>>
> db_user;
db_user.<span class=3D"pl-smi" style=3D"box-sizing: border-box;">get</s=
pan><tag<<span class=3D"pl-s" style=3D"box-sizing: border-box; color:=
rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-box;=
">"</span>name<span class=3D"pl-pds" style=3D"box-sizing: border-box;"=
>"</span></span>>>(<span class=3D"pl-c1" style=3D"box-sizing: bo=
rder-box; color: rgb(0, 134, 179);">id</span>(<span class=3D"pl-c1" style=
=3D"box-sizing: border-box; color: rgb(0, 134, 179);">10</span>));
db_user.<span class=3D"pl-smi" style=3D"box-sizing: border-box;">get</s=
pan><tag<<span class=3D"pl-s" style=3D"box-sizing: border-box; color:=
rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-box;=
">"</span>age<span class=3D"pl-pds" style=3D"box-sizing: border-box;">=
"</span></span>>>(<span class=3D"pl-c1" style=3D"box-sizing: bor=
der-box; color: rgb(0, 134, 179);">id</span>(<span class=3D"pl-c1" style=3D=
"box-sizing: border-box; color: rgb(0, 134, 179);">10</span>));
}</pre></em><em style=3D"box-sizing: border-box; color: rgb(51, 51, 51); fo=
nt-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helveti=
ca, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji&=
quot;, "Segoe UI Symbol"; font-size: 16px;"><p style=3D"box-sizin=
g: border-box; font-style: normal;"><br></p><p style=3D"box-sizing: border-=
box; font-style: normal;">Another example:<br></p><pre style=3D"box-sizing:=
border-box; font-family: Consolas, "Liberation Mono", Menlo, Cou=
rier, monospace; font-size: 13.6px; font-style: normal; font-stretch: norma=
l; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; bac=
kground-color: rgb(247, 247, 247); border-radius: 3px; word-break: normal;"=
><span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, =
93);">template </span><<span class=3D"pl-k" style=3D"box-sizing: border-=
box; color: rgb(167, 29, 93);">typename</span> F, std::<span class=3D"pl-c1=
" style=3D"box-sizing: border-box; color: rgb(0, 134, 179);">size_t</span> =
.... I>
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">constexpr</span> <span class=3D"pl-k" style=3D"box-sizing: border-box;=
color: rgb(167, 29, 93);">auto</span> <span class=3D"pl-en" style=3D"box-s=
izing: border-box; color: rgb(121, 93, 163);">string_builder</span>(F f, st=
d::index_sequence<I...>)
{
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29,=
93);">return</span> char_sequence<<span class=3D"pl-c1" style=3D"box-si=
zing: border-box; color: rgb(0, 134, 179);">f</span>(I)...>{};
}
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">template</span><<b><u>magic</u> </b>TS>
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">auto</span> <span class=3D"pl-en" style=3D"box-sizing: border-box; col=
or: rgb(121, 93, 163);">tag</span>(TS s)
{
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 2=
9, 93);">return</span> <span class=3D"pl-c1" style=3D"box-sizing: border-bo=
x; color: rgb(0, 134, 179);">string_builder</span>([]() <span class=3D"pl-k=
" style=3D"box-sizing: border-box; color: rgb(167, 29, 93);">constexpr</spa=
n> { <span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, =
29, 93);">return</span> s; }, <span class=3D"pl-c1" style=3D"box-sizing: bo=
rder-box; color: rgb(0, 134, 179);">magic_sizeof</span>(s));
}
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">int</span> <span class=3D"pl-en" style=3D"box-sizing: border-box; colo=
r: rgb(121, 93, 163);">main</span>()
{
<span class=3D"pl-c1" style=3D"box-sizing: border-box; color: rgb(0, 13=
4, 179);">static_assert</span>(<span class=3D"pl-c1" style=3D"box-sizing: b=
order-box; color: rgb(0, 134, 179);">is_same</span>(<span class=3D"pl-c1" s=
tyle=3D"box-sizing: border-box; color: rgb(0, 134, 179);">decltype</span>(<=
span class=3D"pl-c1" style=3D"box-sizing: border-box; color: rgb(0, 134, 17=
9);">tag</span>(<span class=3D"pl-s" style=3D"box-sizing: border-box; color=
: rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-box=
;">"</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;">=
"</span></span>)), <span class=3D"pl-c1" style=3D"box-sizing: border-b=
ox; color: rgb(0, 134, 179);">decltype</span>(<span class=3D"pl-c1" style=
=3D"box-sizing: border-box; color: rgb(0, 134, 179);">tag</span>(<span clas=
s=3D"pl-s" style=3D"box-sizing: border-box; color: rgb(24, 54, 145);"><span=
class=3D"pl-pds" style=3D"box-sizing: border-box;">"</span>hi<span cl=
ass=3D"pl-pds" style=3D"box-sizing: border-box;">"</span></span>))));
<span class=3D"pl-c1" style=3D"box-sizing: border-box; color: rgb(0, 13=
4, 179);">static_assert</span>(!<span class=3D"pl-c1" style=3D"box-sizing: =
border-box; color: rgb(0, 134, 179);">is_same</span>(<span class=3D"pl-c1" =
style=3D"box-sizing: border-box; color: rgb(0, 134, 179);">decltype</span>(=
<span class=3D"pl-c1" style=3D"box-sizing: border-box; color: rgb(0, 134, 1=
79);">tag</span>(<span class=3D"pl-s" style=3D"box-sizing: border-box; colo=
r: rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-bo=
x;">"</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;"=
>"</span></span>)), <span class=3D"pl-c1" style=3D"box-sizing: border-=
box; color: rgb(0, 134, 179);">decltype</span>(<span class=3D"pl-c1" style=
=3D"box-sizing: border-box; color: rgb(0, 134, 179);">tag</span>(<span clas=
s=3D"pl-s" style=3D"box-sizing: border-box; color: rgb(24, 54, 145);"><span=
class=3D"pl-pds" style=3D"box-sizing: border-box;">"</span>bye<span c=
lass=3D"pl-pds" style=3D"box-sizing: border-box;">"</span></span>))));
}</pre></em><span style=3D"box-sizing: border-box; color: rgb(51, 51, 51); =
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helve=
tica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoj=
i", "Segoe UI Symbol"; font-size: 16px;"><p style=3D"font-st=
yle: normal; box-sizing: border-box;"><br>The above examples show the defin=
ition of unique types based on strings=C2=A0<span style=3D"box-sizing: bord=
er-box; font-weight: 600;">in-situ without using macros</span>. (It is=C2=
=A0<a href=3D"https://github.com/irrequietus/typestring" style=3D"box-sizin=
g: border-box; color: rgb(64, 120, 192);">already possible with macros</a>.=
)<br>The problem is that there currently is nothing in the language that co=
uld be used as "<u style=3D"font-weight: bold;">magic</u>".<br><e=
m style=3D"box-sizing: border-box;"></em></p><p style=3D"font-style: normal=
; box-sizing: border-box;"><br></p>Therefore I propose=C2=A0</span><span st=
yle=3D"color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFo=
nt, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color E=
moji", "Segoe UI Emoji", "Segoe UI Symbol"; font-s=
ize: 16px;">that, to avoid ambiguity,=C2=A0</span><code style=3D"box-sizing=
: border-box; font-family: Consolas, "Liberation Mono", Menlo, Co=
urier, monospace; font-size: 13.6px; padding-top: 0.2em; padding-bottom: 0.=
2em; background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; color:=
rgb(51, 51, 51);">magic</code><span style=3D"color: rgb(51, 51, 51); font-=
family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,=
Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji&quo=
t;, "Segoe UI Symbol"; font-size: 16px;">=C2=A0should simply be a=
=C2=A0</span><code style=3D"box-sizing: border-box; font-family: Consolas, =
"Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; =
padding-top: 0.2em; padding-bottom: 0.2em; background-color: rgba(0, 0, 0, =
0.0392157); border-radius: 3px; color: rgb(51, 51, 51);">char...</code><spa=
n style=3D"color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSyst=
emFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Col=
or Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; fo=
nt-size: 16px;">=C2=A0pack. <br><b>A=C2=A0</b></span><b><em style=3D"box-si=
zing: border-box; color: rgb(51, 51, 51); font-family: -apple-system, Blink=
MacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Ap=
ple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol&qu=
ot;; font-size: 16px;">special rule</em><span style=3D"color: rgb(51, 51, 5=
1); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", H=
elvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI =
Emoji", "Segoe UI Symbol"; font-size: 16px;">=C2=A0would be =
added to the standard that allows string literals to be matched into=C2=A0<=
/span><code style=3D"box-sizing: border-box; font-family: Consolas, "L=
iberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding=
-top: 0.2em; padding-bottom: 0.2em; background-color: rgba(0, 0, 0, 0.03921=
57); border-radius: 3px; color: rgb(51, 51, 51);">char...</code><span style=
=3D"color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont,=
"Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoj=
i", "Segoe UI Emoji", "Segoe UI Symbol"; font-size=
: 16px;">=C2=A0packs as template parameters.</span></b></div><div><b><span =
style=3D"color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystem=
Font, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color=
Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font=
-size: 16px;"><br></span></b></div><div><div class=3D"highlight highlight-s=
ource-c++" style=3D"box-sizing: border-box; margin-bottom: 16px; color: rgb=
(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, "Segoe U=
I", Helvetica, Arial, sans-serif, "Apple Color Emoji", "=
;Segoe UI Emoji", "Segoe UI Symbol"; font-size: 16px;"><pre =
style=3D"box-sizing: border-box; font-family: Consolas, "Liberation Mo=
no", Menlo, Courier, monospace; font-size: 13.6px; font-stretch: norma=
l; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; bac=
kground-color: rgb(247, 247, 247); border-radius: 3px; word-break: normal;"=
><span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, =
93);">template</span><<span class=3D"pl-k" style=3D"box-sizing: border-b=
ox; color: rgb(167, 29, 93);">typename</span>> <span class=3D"pl-k" styl=
e=3D"box-sizing: border-box; color: rgb(167, 29, 93);">struct</span> <span =
class=3D"pl-en" style=3D"box-sizing: border-box; color: rgb(121, 93, 163);"=
>t_typename</span>{};
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">template</span><<span class=3D"pl-k" style=3D"box-sizing: border-bo=
x; color: rgb(167, 29, 93);">const</span> <span class=3D"pl-k" style=3D"box=
-sizing: border-box; color: rgb(167, 29, 93);">char</span>*> <span class=
=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 93);">struct=
</span> <span class=3D"pl-en" style=3D"box-sizing: border-box; color: rgb(1=
21, 93, 163);">t_constchar</span>{};
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">template</span><<span class=3D"pl-k" style=3D"box-sizing: border-bo=
x; color: rgb(167, 29, 93);">const</span> <span class=3D"pl-en" style=3D"bo=
x-sizing: border-box; color: rgb(121, 93, 163);">char</span>(&)[3]> =
struct t_charref{};
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">template</span><<span class=3D"pl-k" style=3D"box-sizing: border-bo=
x; color: rgb(167, 29, 93);">char</span>...> <span class=3D"pl-k" style=
=3D"box-sizing: border-box; color: rgb(167, 29, 93);">struct</span> <span c=
lass=3D"pl-en" style=3D"box-sizing: border-box; color: rgb(121, 93, 163);">=
t_chars</span>{};
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">template</span><<span class=3D"pl-k" style=3D"box-sizing: border-bo=
x; color: rgb(167, 29, 93);">auto</span>> <span class=3D"pl-k" style=3D"=
box-sizing: border-box; color: rgb(167, 29, 93);">struct</span> <span class=
=3D"pl-en" style=3D"box-sizing: border-box; color: rgb(121, 93, 163);">t_au=
to</span>{};
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">template</span><<span class=3D"pl-k" style=3D"box-sizing: border-bo=
x; color: rgb(167, 29, 93);">auto</span>...> <span class=3D"pl-k" style=
=3D"box-sizing: border-box; color: rgb(167, 29, 93);">struct</span> <span c=
lass=3D"pl-en" style=3D"box-sizing: border-box; color: rgb(121, 93, 163);">=
t_autos</span>{};
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">int</span> <span class=3D"pl-en" style=3D"box-sizing: border-box; colo=
r: rgb(121, 93, 163);">main</span>()
{
t_typename<<span class=3D"pl-s" style=3D"box-sizing: border-box; col=
or: rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-b=
ox;">"</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;=
">"</span></span>>{}; <span class=3D"pl-c" style=3D"box-sizing: bor=
der-box; color: rgb(150, 152, 150);">// still would FAIL to compile, as int=
ended</span>
t_constchar<<span class=3D"pl-s" style=3D"box-sizing: border-box; co=
lor: rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-=
box;">"</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box=
;">"</span></span>>{}; <span class=3D"pl-c" style=3D"box-sizing: bo=
rder-box; color: rgb(150, 152, 150);">// still would FAIL to compile, as in=
tended</span>
t_charref<<span class=3D"pl-s" style=3D"box-sizing: border-box; colo=
r: rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-bo=
x;">"</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;"=
>"</span></span>>{}; <span class=3D"pl-c" style=3D"box-sizing: bord=
er-box; color: rgb(150, 152, 150);">// still would FAIL to compile, as inte=
nded</span>
t_chars<<span class=3D"pl-s" style=3D"box-sizing: border-box; color:=
rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-box;=
">"</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;">&=
quot;</span></span>>{}; <span class=3D"pl-c" style=3D"box-sizing: border=
-box; color: rgb(150, 152, 150);">// <b>should COMPILE with the proposed ch=
anges</b></span>
t_auto<<span class=3D"pl-s" style=3D"box-sizing: border-box; color: =
rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-box;"=
>"</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;">&q=
uot;</span></span>>{}; <span class=3D"pl-c" style=3D"box-sizing: border-=
box; color: rgb(150, 152, 150);">// still would FAIL to compile, as intende=
d</span>
t_autos<<span class=3D"pl-s" style=3D"box-sizing: border-box; color:=
rgb(24, 54, 145);"><span class=3D"pl-pds" style=3D"box-sizing: border-box;=
">"</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;">&=
quot;</span></span>>{}; <span class=3D"pl-c" style=3D"box-sizing: border=
-box; color: rgb(150, 152, 150);">// <b>should COMPILE with the proposed ch=
anges</b></span>
}</pre></div><p style=3D"box-sizing: border-box; margin-bottom: 16px; color=
: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, "Se=
goe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", =
"Segoe UI Emoji", "Segoe UI Symbol"; font-size: 16px;">=
Using=C2=A0<code style=3D"box-sizing: border-box; font-family: Consolas, &q=
uot;Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; pa=
dding-top: 0.2em; padding-bottom: 0.2em; background-color: rgba(0, 0, 0, 0.=
0392157); border-radius: 3px;">char...</code>=C2=A0instead of pointers/refe=
rence would make the literal behave just a sequence of compile-time charact=
ers.</p><p style=3D"box-sizing: border-box; margin-bottom: 16px; color: rgb=
(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, "Segoe U=
I", Helvetica, Arial, sans-serif, "Apple Color Emoji", "=
;Segoe UI Emoji", "Segoe UI Symbol"; font-size: 16px;"><br><=
/p><p style=3D"box-sizing: border-box; margin-bottom: 16px; color: rgb(51, =
51, 51); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI&quo=
t;, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Sego=
e UI Emoji", "Segoe UI Symbol"; font-size: 16px;">What do yo=
u think? <br>The same problem is addressed by <a href=3D"http://www.open-st=
d.org/jtc1/sc22/wg21/docs/papers/2016/p0424r0.pdf">P0424R0</a>, but only fo=
r user-defined literals.<br><br>I think that allowing string literals to be=
matched into template=C2=A0<span style=3D"font-family: Consolas, "Lib=
eration Mono", Menlo, Courier, monospace; font-size: 13.6px; backgroun=
d-color: rgba(0, 0, 0, 0.0392157);">char...</span>=C2=A0argument packs woul=
d make sense, because the programmer only cares about the literal's &qu=
ot;characters" <i>(not its address) </i>at compile-time.</p></div></di=
v>
<p></p>
-- <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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/9de07b5f-f870-4a02-882f-54f9fdd12ffd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9de07b5f-f870-4a02-882f-54f9fdd12ffd=
%40isocpp.org</a>.<br />
------=_Part_2580_1140857293.1479305072521--
------=_Part_2579_485815145.1479305072521--
.