220 8154 <e2b8cee3-0977-4338-a7d9-d7876bffec2c@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Michael Price - Dev <michael.b.price.dev@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: A compile-time string literal library type
Date: Tue, 17 Dec 2013 19:45:54 -0800 (PST)
Lines: 242
Approved: news@gmane.org
Message-ID: <e2b8cee3-0977-4338-a7d9-d7876bffec2c@isocpp.org>
References: <d9fcae4a-7452-4660-8053-1386f851951f@isocpp.org>
 <CAGsORuAv7xKEXMsUfWd04tkBULXRVM90RqQguJfdqkX1KbLsPg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_2517_23319239.1387338354477"
X-Trace: ger.gmane.org 1387338349 8690 80.91.229.3 (18 Dec 2013 03:45:49 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 18 Dec 2013 03:45:49 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC63BP4Z2YBRB45UYSKQKGQEMHIEISA@isocpp.org Wed Dec 18 04:45:57 2013
Return-path: <std-proposals+bncBC63BP4Z2YBRB45UYSKQKGQEMHIEISA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ie0-f200.google.com ([209.85.223.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC63BP4Z2YBRB45UYSKQKGQEMHIEISA@isocpp.org>)
	id 1Vt856-0002eD-Ub
	for gclcip-std-proposals@m.gmane.org; Wed, 18 Dec 2013 04:45:57 +0100
Original-Received: by mail-ie0-f200.google.com with SMTP id at1sf25425185iec.7
        for <gclcip-std-proposals@m.gmane.org>; Tue, 17 Dec 2013 19:45:56 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=Lpja7U9CReFepqlSkryckLMkSwvayab6Mm7Ztp31rTw=;
        b=NJq5yzCkNhv9o+wVJ6qah/BI6t6eR12u6u47xcq+EN5hU+n9KUVq5v7RNGeko7nw91
         qIEenWKi7ESGgAuhfOxzxMEbpzp8pleFNRVXQIUXUuPrbO5wuih0L+wcgV5E9ZU9PCqW
         kKiZ+T56MB+voW9KoB0bxdNJwYIqA1PVIbxxuryNtkAAwB+f0UOBGh7D6IptTWlTufa3
         wVLF2JnqHC/O9k2W+i2g7NXVBLPxsxwhckdwP2HzfBsZaD30rpOpWZoXphEhMJ9WZX25
         W04gQev//BI3KuvZzTDVrdFacUbiJXfs6Iy3JiFOEYDZAj5Flb4glnizotGL8Y5EFsuA
         GJdw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=Lpja7U9CReFepqlSkryckLMkSwvayab6Mm7Ztp31rTw=;
        b=DWMa2lUOmRrgYn7/3aH4WR+wA43S5j9kKkB8N0xy1wImrqsk5XWWNyN+Q9LCFMZKpr
         zwrkxtT+LCSEgQlAMpXaRsb6GvvI1i9tfpHskWD8ycoXTSfjLY0mF4O195BRQ+3r0Dmb
         kubMBCN4Q/q/5xIny6UeY9kRyVlVrt6RHh+M9J/lXzJ5A5bTfpIVeaJ6BVjxdAqKuWmU
         RGppDiXx1ZuPoa1bddw4IkMjmqhqznl2TUNfqO0SwX3lPB2AiZu7JzViRrXmCaAYa7Qc
         DJKnL3Yk/CfStXKbB8AWnZrrlESXeAtt7KMPhm7ItKT2Kyoec2YAn3PAKMxfLpcJFdsW
         Vmbw==
X-Gm-Message-State: ALoCoQmYCwmsWZX1TEF5Hhn94blfg1w/MbDuTQZaekk26luKb4Uvv3qs78Uul9HAwozpDO7mmyER
X-Received: by 10.182.111.227 with SMTP id il3mr4189908obb.41.1387338356015;
        Tue, 17 Dec 2013 19:45:56 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.126.227 with SMTP id nb3ls1043935obb.5.gmail; Tue, 17 Dec
 2013 19:45:55 -0800 (PST)
X-Received: by 10.182.113.194 with SMTP id ja2mr1843obb.31.1387338354999;
        Tue, 17 Dec 2013 19:45:54 -0800 (PST)
In-Reply-To: <CAGsORuAv7xKEXMsUfWd04tkBULXRVM90RqQguJfdqkX1KbLsPg@mail.gmail.com>
X-Original-Sender: michael.b.price.dev@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:8154
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8154>

------=_Part_2517_23319239.1387338354477
Content-Type: text/plain; charset=ISO-8859-1



On Sunday, December 15, 2013 10:52:52 PM UTC-6, Zhihao Yuan wrote:
>
> On Sun, Dec 15, 2013 at 10:26 PM, Michael Price - Dev 
> <michael.b...@gmail.com <javascript:>> wrote: 
> > I'm considering writing up a proposal to standardize a library type that 
> > represents a compile-time sequence of character literals.  I'm looking 
> for a 
> > first round of feedback.  You can view my prototype implementation at 
> > 
> https://github.com/michaelbprice/cxx_snippets/blob/master/string_literal/string_literal.cpp 
> > 
> > I'm using the top-of-trunk clang to compile with the following 
> command-line: 
>
> I think you know that the language feature you used 
>
>   http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3599.html 
>
> is not a part of C++14. 
>

Actually, I was unaware, although I had stumbled upon clang's 
implementation of said feature mostly by mistake.  I'm not intending this 
for inclusion in C++14, but rather the next version out.  I've contacted 
the author of that proposal to see about addressing the straw poll 
concerns. 
 

> Anyway. 
>
> What's the different between `make_array("str")` and "str"_cs? 
>
>   http://isocpp.org/files/papers/N3824.html 
>
>  1. string_literalS are different in types (works with template); 
>  2. string_literal cannot be modified; 
>  3. string_literal has some algorithms as member functions. 
>
> So what is the problem you want to solve?  Compile-time parsing? 
> If so, Bristol EWG says: 
>
>  1. don't think template instantiations is the only way to do it; 
>  2. doubt user to overuse it (a compile time SQL parser is fun, 
>     but what you gain?); 
>  3. need use cases.
>

My initially motivating use case was as a proof for yet another change that 
I will be proposing regarding the message for static_assert.  Example:


constexpr auto library_name = "BEST"_cs;
constexpr auto static_prefix = library_name + ": "_cs;

static_assert(false, static_prefix + "Oops, did I say false"); // would 
print: "BEST: Oops, did I say false"


Of course, there's lots of other potential uses. See 
http://2012.cppnow.org/session/metaparse-complie-time-parsing-with-template-metaprogramming/ for 
instance (won best presentation award at C++Now 2012).  I can't even begin 
to imagine all of the cool ways that this type of thing could be used.

For me, the idea that in order to get a rich interface for strings, one 
must succumb to the run-time penalty of std::string is just counter to one 
of the ideas of fundamental underpinnings of C++, namely that we don't make 
people pay for the things that they don't need. This is very much the same 
rationale behind std::array (vs. C-arrays or std::vector).
 

> -- 
> Zhihao Yuan, ID lichray 
> The best way to predict the future is to invent it. 
> ___________________________________________________ 
> 4BSD -- http://4bsd.biz/ 
>

-- 

--- 
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_2517_23319239.1387338354477
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Sunday, December 15, 2013 10:52:52 PM UTC-6, Zh=
ihao Yuan wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Sun, Dec 15=
, 2013 at 10:26 PM, Michael Price - Dev
<br>&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
5qo-PrZpX9cJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">michael.b...@gmail.com</a><wbr=
>&gt; wrote:
<br>&gt; I'm considering writing up a proposal to standardize a library typ=
e that
<br>&gt; represents a compile-time sequence of character literals. &nbsp;I'=
m looking for a
<br>&gt; first round of feedback. &nbsp;You can view my prototype implement=
ation at
<br>&gt; <a href=3D"https://github.com/michaelbprice/cxx_snippets/blob/mast=
er/string_literal/string_literal.cpp" target=3D"_blank" onmousedown=3D"this=
..href=3D'https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fmichaelb=
price%2Fcxx_snippets%2Fblob%2Fmaster%2Fstring_literal%2Fstring_literal.cpp\=
46sa\75D\46sntz\0751\46usg\75AFQjCNHDIcuYw_Yf8S9R5qayIKLy8_grmQ';return tru=
e;" onclick=3D"this.href=3D'https://www.google.com/url?q\75https%3A%2F%2Fgi=
thub.com%2Fmichaelbprice%2Fcxx_snippets%2Fblob%2Fmaster%2Fstring_literal%2F=
string_literal.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNHDIcuYw_Yf8S9R5qayIKL=
y8_grmQ';return true;">https://github.com/<wbr>michaelbprice/cxx_snippets/<=
wbr>blob/master/string_literal/<wbr>string_literal.cpp</a>
<br>&gt;
<br>&gt; I'm using the top-of-trunk clang to compile with the following com=
mand-line:
<br>
<br>I think you know that the language feature you used
<br>
<br>&nbsp; <a href=3D"http://www.open-std.org/JTC1/SC22/WG21/docs/papers/20=
13/n3599.html" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\75http%3A%2F%2Fwww.open-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2=
Fpapers%2F2013%2Fn3599.html\46sa\75D\46sntz\0751\46usg\75AFQjCNFTsjvenjSuqF=
nBIgHDgCrqAqUOEA';return true;" onclick=3D"this.href=3D'http://www.google.c=
om/url?q\75http%3A%2F%2Fwww.open-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpape=
rs%2F2013%2Fn3599.html\46sa\75D\46sntz\0751\46usg\75AFQjCNFTsjvenjSuqFnBIgH=
DgCrqAqUOEA';return true;">http://www.open-std.org/JTC1/<wbr>SC22/WG21/docs=
/papers/2013/<wbr>n3599.html</a>
<br>
<br>is not a part of C++14.&nbsp;<br></blockquote><div><br></div><div>Actua=
lly, I was unaware, although I had stumbled upon clang's implementation of =
said feature mostly by mistake. &nbsp;I'm not intending this for inclusion =
in C++14, but rather the next version out. &nbsp;I've contacted the author =
of that proposal to see about addressing the straw poll concerns.&nbsp;</di=
v><div>&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Anyway.
<br>
<br>What's the different between `make_array("str")` and "str"_cs?
<br>
<br>&nbsp; <a href=3D"http://isocpp.org/files/papers/N3824.html" target=3D"=
_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2=
F%2Fisocpp.org%2Ffiles%2Fpapers%2FN3824.html\46sa\75D\46sntz\0751\46usg\75A=
FQjCNH8WrwPehw5g_VYjNE0i22564C5IA';return true;" onclick=3D"this.href=3D'ht=
tp://www.google.com/url?q\75http%3A%2F%2Fisocpp.org%2Ffiles%2Fpapers%2FN382=
4.html\46sa\75D\46sntz\0751\46usg\75AFQjCNH8WrwPehw5g_VYjNE0i22564C5IA';ret=
urn true;">http://isocpp.org/files/<wbr>papers/N3824.html</a>
<br>
<br>&nbsp;1. string_literalS are different in types (works with template);
<br>&nbsp;2. string_literal cannot be modified;
<br>&nbsp;3. string_literal has some algorithms as member functions.
<br>
<br>So what is the problem you want to solve? &nbsp;Compile-time parsing?
<br>If so, Bristol EWG says:
<br>
<br>&nbsp;1. don't think template instantiations is the only way to do it;
<br>&nbsp;2. doubt user to overuse it (a compile time SQL parser is fun,
<br>&nbsp; &nbsp; but what you gain?);
<br>&nbsp;3. need use cases.<br></blockquote><div><br></div><div>My initial=
ly motivating use case was as a proof for yet another change that I will be=
 proposing regarding the message for static_assert. &nbsp;Example:</div><di=
v><br></div><div><div class=3D"prettyprint" style=3D"background-color: rgb(=
250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: break-word=
;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">constexpr</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> library_name </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-b=
y-prettify">"BEST"</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">_cs</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> static_prefix </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> library_name </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">+</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #08=
0;" class=3D"styled-by-prettify">": "</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">_cs</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><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">static_assert</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">false</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> static_pre=
fix </span><span style=3D"color: #660;" class=3D"styled-by-prettify">+</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">"Oops, did I say false"<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">// would print: "BEST: Oops,=
 did I say false"</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br><br></span><font color=3D"#008800"></font></div></code></div><br=
>Of course, there's lots of other potential uses. See&nbsp;<a href=3D"http:=
//2012.cppnow.org/session/metaparse-complie-time-parsing-with-template-meta=
programming/">http://2012.cppnow.org/session/metaparse-complie-time-parsing=
-with-template-metaprogramming/</a>&nbsp;for instance (won best presentatio=
n award at C++Now 2012). &nbsp;I can't even begin to imagine all of the coo=
l ways that this type of thing could be used.</div><div><br></div><div>For =
me, the idea that in order to get a rich interface for strings, one must su=
ccumb to the run-time penalty of std::string is just counter to one of the =
ideas of fundamental underpinnings of C++, namely that we don't make people=
 pay for the things that they don't need. This is very much the same ration=
ale behind std::array (vs. C-arrays or std::vector).</div><div>&nbsp;</div>=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;">--=20
<br>Zhihao Yuan, ID lichray
<br>The best way to predict the future is to invent it.
<br>______________________________<wbr>_____________________
<br>4BSD -- <a href=3D"http://4bsd.biz/" target=3D"_blank" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\75http%3A%2F%2F4bsd.biz%2F\46sa\75D=
\46sntz\0751\46usg\75AFQjCNEEohiBBmXaBWMbzqBFWtWEgT5t9g';return true;" oncl=
ick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2F4bsd.biz%2F\=
46sa\75D\46sntz\0751\46usg\75AFQjCNEEohiBBmXaBWMbzqBFWtWEgT5t9g';return tru=
e;">http://4bsd.biz/</a>
<br></blockquote></div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 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_2517_23319239.1387338354477--

.
