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, &quot;Segoe UI&quot;, Helvetica, Arial, sans-s=
erif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Sego=
e UI Symbol&quot;; 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, &quot;Segoe UI&quot;, Helvetica=
, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&qu=
ot;, &quot;Segoe UI Symbol&quot;; 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,=
 &quot;Liberation Mono&quot;, 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>&lt;<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&gt; <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&lt;<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;">&quot;<=
/span></span>&gt; a{};
    t&lt;<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;">&quot;<=
/span></span>&gt; b{};
}
<pre style=3D"box-sizing: border-box; font-family: Consolas, &quot;Liberati=
on Mono&quot;, 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, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif=
, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI=
 Symbol&quot;; 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&#39;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&quot;, 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>&lt;<b><u>magic</u>=
 </b>TS&gt; <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&lt;tag&lt;<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;">&quot;</span>user<span class=3D"pl-pds" style=3D"box-sizin=
g: border-box;">&quot;</span></span>&gt;,
        database::field&lt;tag&lt;<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;">&quot;</span>name<span class=3D"pl-pds" style=3D"box-s=
izing: border-box;">&quot;</span></span>&gt;, std::string&gt;,
        database::field&lt;tag&lt;<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;">&quot;</span>age<span class=3D"pl-pds" style=3D"box-si=
zing: border-box;">&quot;</span></span>&gt;, <span class=3D"pl-k" style=3D"=
box-sizing: border-box; color: rgb(167, 29, 93);">int</span>&gt;
    &gt; db_user;

    db_user.<span class=3D"pl-smi" style=3D"box-sizing: border-box;">get</s=
pan>&lt;tag&lt;<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;=
">&quot;</span>name<span class=3D"pl-pds" style=3D"box-sizing: border-box;"=
>&quot;</span></span>&gt;&gt;(<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>&lt;tag&lt;<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;=
">&quot;</span>age<span class=3D"pl-pds" style=3D"box-sizing: border-box;">=
&quot;</span></span>&gt;&gt;(<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, &quot;Segoe UI&quot;, Helveti=
ca, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&=
quot;, &quot;Segoe UI Symbol&quot;; 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, &quot;Liberation Mono&quot;, 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>&lt;<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&gt;
<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&lt;I...&gt;)
{
  <span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29,=
 93);">return</span> char_sequence&lt;<span class=3D"pl-c1" style=3D"box-si=
zing: border-box; color: rgb(0, 134, 179);">f</span>(I)...&gt;{};
}

<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">template</span>&lt;<b><u>magic</u> </b>TS&gt;
<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=
;">&quot;</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;">=
&quot;</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;">&quot;</span>hi<span cl=
ass=3D"pl-pds" style=3D"box-sizing: border-box;">&quot;</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;">&quot;</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;"=
>&quot;</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;">&quot;</span>bye<span c=
lass=3D"pl-pds" style=3D"box-sizing: border-box;">&quot;</span></span>))));
}</pre></em><span style=3D"box-sizing: border-box; color: rgb(51, 51, 51); =
font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helve=
tica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoj=
i&quot;, &quot;Segoe UI Symbol&quot;; 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 &quot;<u style=3D"font-weight: bold;">magic</u>&quot;.<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, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color E=
moji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-s=
ize: 16px;">that, to avoid ambiguity,=C2=A0</span><code style=3D"box-sizing=
: border-box; font-family: Consolas, &quot;Liberation Mono&quot;, 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, &quot;Segoe UI&quot;, Helvetica,=
 Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quo=
t;, &quot;Segoe UI Symbol&quot;; font-size: 16px;">=C2=A0should simply be a=
=C2=A0</span><code style=3D"box-sizing: border-box; font-family: Consolas, =
&quot;Liberation Mono&quot;, 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, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Col=
or Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; 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, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Ap=
ple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;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, &quot;Segoe UI&quot;, H=
elvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI =
Emoji&quot;, &quot;Segoe UI Symbol&quot;; 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, &quot;L=
iberation Mono&quot;, 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,=
 &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoj=
i&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; 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, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color=
 Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; 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, &quot;Segoe U=
I&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot=
;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px;"><pre =
style=3D"box-sizing: border-box; font-family: Consolas, &quot;Liberation Mo=
no&quot;, 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>&lt;<span class=3D"pl-k" style=3D"box-sizing: border-b=
ox; color: rgb(167, 29, 93);">typename</span>&gt; <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>&lt;<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>*&gt; <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>&lt;<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>(&amp;)[3]&gt; =
struct t_charref{};
<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(167, 29, 9=
3);">template</span>&lt;<span class=3D"pl-k" style=3D"box-sizing: border-bo=
x; color: rgb(167, 29, 93);">char</span>...&gt; <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>&lt;<span class=3D"pl-k" style=3D"box-sizing: border-bo=
x; color: rgb(167, 29, 93);">auto</span>&gt; <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>&lt;<span class=3D"pl-k" style=3D"box-sizing: border-bo=
x; color: rgb(167, 29, 93);">auto</span>...&gt; <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&lt;<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;">&quot;</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;=
">&quot;</span></span>&gt;{}; <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&lt;<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;">&quot;</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box=
;">&quot;</span></span>&gt;{}; <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&lt;<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;">&quot;</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;"=
>&quot;</span></span>&gt;{}; <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&lt;<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;=
">&quot;</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;">&=
quot;</span></span>&gt;{}; <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&lt;<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;"=
>&quot;</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;">&q=
uot;</span></span>&gt;{}; <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&lt;<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;=
">&quot;</span>hi<span class=3D"pl-pds" style=3D"box-sizing: border-box;">&=
quot;</span></span>&gt;{}; <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, &quot;Se=
goe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, =
&quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px;">=
Using=C2=A0<code style=3D"box-sizing: border-box; font-family: Consolas, &q=
uot;Liberation Mono&quot;, 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, &quot;Segoe U=
I&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot=
;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; 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, &quot;Segoe UI&quo=
t;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Sego=
e UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; 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, &quot;Lib=
eration Mono&quot;, 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&#39;s &qu=
ot;characters&quot; <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&quot; 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--

.