Topic: Rationale for keeping n in string_literal<n>?


Author: german.gomez@personifyinc.com
Date: Tue, 2 Sep 2014 22:19:27 -0700 (PDT)
Raw View
------=_Part_1771_1281488442.1409721567236
Content-Type: text/plain; charset=UTF-8

Hello everyone,

I wonder why the size of n is kept in this compile-time string
implementation:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4121.pdf


The problem I see, but I must be missing something, is that if I want to
pass a template argument for a compile-time string, I must match the size.

so:

template <string_literal<n> const & str>
struct MyStruct {

};

will demand a string of exactly size n. I have seen some other constexpr
implementations that do not take n as a template paramter.
Wouldn't this be a superior solution or we would lose something on the way
to size erasure?

Regards

--

---
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_1771_1281488442.1409721567236
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello everyone,<div><br></div><div>I wonder why the size o=
f n is kept in this compile-time string implementation:</div><div><br></div=
><div>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4121.pdf<br>=
</div><div><br></div><div><br></div><div>The problem I see, but I must be m=
issing something, is that if I want to pass a template argument for a compi=
le-time string, I must match the size.</div><div><br></div><div>so:</div><d=
iv><br></div><div>template &lt;string_literal&lt;n&gt; const &amp; str&gt;<=
/div><div>struct MyStruct {</div><div><br></div><div>};</div><div><br></div=
><div>will demand a string of exactly size n. I have seen some other conste=
xpr implementations that do not take n as a template paramter.</div><div>Wo=
uldn't this be a superior solution or we would lose something on the way to=
 size erasure?</div><div><br></div><div>Regards</div><div><br></div></div>

<p></p>

-- <br />
<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 <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 />
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_1771_1281488442.1409721567236--

.


Author: David Krauss <potswa@gmail.com>
Date: Wed, 3 Sep 2014 14:09:11 +0800
Raw View
On 2014-09-03, at 1:19 PM, german.gomez@personifyinc.com wrote:

> Hello everyone,
>
> I wonder why the size of n is kept in this compile-time string implementation:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4121.pdf

The answer is at the top of page 2.

--

---
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/.

.


Author: german.gomez@personifyinc.com
Date: Wed, 3 Sep 2014 00:28:21 -0700 (PDT)
Raw View
------=_Part_591_218975436.1409729301177
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Wednesday, September 3, 2014 1:09:17 PM UTC+7, David Krauss wrote:
>
>
> On 2014=E2=80=9309=E2=80=9303, at 1:19 PM, german...@personifyinc.com <ja=
vascript:>=20
> wrote:=20
>
> > Hello everyone,=20
> >=20
> > I wonder why the size of n is kept in this compile-time string=20
> implementation:=20
> >=20
> > http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4121.pdf=20
>
> The answer is at the top of page 2.=20
>
>
I don't think this a satisfactory reply for what I was asking:

- Why, <n> is made part of the type. If you take a look closely, you will=
=20
see that template<const std::string_literal<n>& s, typename T> struct x=CD=
=BE=20
needs the <n> when passing the string for metaprogramming.

This means we must exactly match that <n> when metaprogramming. So my=20
question was, if n is not made part of the type, doesn't this make the=20
design more flexible and equally powerful?

For example, take a look at this design, it does make part of the type the=
=20
contents of the string. Google "A compile-time string library template with=
=20
UDL operator templates" I dont know why I cannot access the link and=20
downloads.

This proposal allows: struct metaprogram<decltype("My metastring"S)>=20

There is an alternative design keeping the size and contents both as a data=
=20
member, without affecting the type. I wonder how that would work with=20
strings as template parameters.



But=20

--=20

---=20
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 e=
mail 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-proposa=
ls/.

------=_Part_591_218975436.1409729301177
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, September 3, 2014 1:09:17 PM UTC+7, =
David Krauss wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>On 2014=E2=80=9309=E2=80=9303, at 1:19 PM, <a href=3D"javascript:" targ=
et=3D"_blank" gdf-obfuscated-mailto=3D"xvaovK-o2i8J" onmousedown=3D"this.hr=
ef=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';retur=
n true;">german...@personifyinc.com</a> wrote:
<br>
<br>&gt; Hello everyone,
<br>&gt;=20
<br>&gt; I wonder why the size of n is kept in this compile-time string imp=
lementation:
<br>&gt;=20
<br>&gt; <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014=
/n4121.pdf" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google=
..com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpa=
pers%2F2014%2Fn4121.pdf\46sa\75D\46sntz\0751\46usg\75AFQjCNHeUsGikfu8O3EAg9=
zdo9r0kjz1bg';return true;" onclick=3D"this.href=3D'http://www.google.com/u=
rl?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2=
F2014%2Fn4121.pdf\46sa\75D\46sntz\0751\46usg\75AFQjCNHeUsGikfu8O3EAg9zdo9r0=
kjz1bg';return true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/pape=
rs/2014/<wbr>n4121.pdf</a>
<br>
<br>The answer is at the top of page 2.
<br>
<br></blockquote><div><br></div><div>I don't think this a satisfactory repl=
y for what I was asking:</div><div><br></div><div>- Why, &lt;n&gt; is made =
part of the type. If you take a look closely, you will see that template&lt=
;const std::string_literal&lt;n&gt;&amp; s, typename T&gt; struct x=CD=BE n=
eeds the &lt;n&gt; when passing the string for metaprogramming.</div><div><=
br></div><div>This means we must exactly match that &lt;n&gt; when metaprog=
ramming. So my question was, if n is not made part of the type, doesn't thi=
s make the design more flexible and equally powerful?</div><div><br></div><=
div>For example, take a look at this design, it does make part of the type =
the contents of the string. Google "A compile-time string library template =
with UDL operator templates" I dont know why I cannot access the link and d=
ownloads.</div><div><br></div><div>This proposal allows: struct metaprogram=
&lt;decltype("My metastring"S)&gt;&nbsp;</div><div><br></div><div>There is =
an alternative design keeping the size and contents both as a data member, =
without affecting the type. I wonder how that would work with strings as te=
mplate parameters.</div><div><br></div><div><br></div><div><br></div><div>B=
ut&nbsp;</div></div>

<p></p>

-- <br />
<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 <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 />
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_591_218975436.1409729301177--

.


Author: german.gomez@personifyinc.com
Date: Wed, 3 Sep 2014 00:47:01 -0700 (PDT)
Raw View
------=_Part_6355_1035062059.1409730421095
Content-Type: text/plain; charset=UTF-8



>
> . I wonder how that would work with strings as template parameters.
>
>
Or if it can work like that at all.

--

---
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_6355_1035062059.1409730421095
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><div><br></div><div>. I wonder how that would work with strings as=
 template parameters.</div><div><br></div></div></blockquote><div>&nbsp;</d=
iv><div>Or if it can work like that at all.</div></div>

<p></p>

-- <br />
<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 <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 />
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_6355_1035062059.1409730421095--

.


Author: Greg Marr <gregmmarr@gmail.com>
Date: Wed, 3 Sep 2014 10:09:32 -0700 (PDT)
Raw View
------=_Part_339_1497286203.1409764172534
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Wednesday, September 3, 2014 3:28:21 AM UTC-4,=20
german...@personifyinc.com wrote:
>
> - Why, <n> is made part of the type. If you take a look closely, you will=
=20
> see that template<const std::string_literal<n>& s, typename T> struct x=
=CD=BE=20
> needs the <n> when passing the string for metaprogramming.
>
> This means we must exactly match that <n> when metaprogramming. So my=20
> question was, if n is not made part of the type, doesn't this make the=20
> design more flexible and equally powerful?
>

Not making it part of the type requires dynamic memory allocation.  The=20
entire point is to eliminate the dynamic memory allocation.
=20

> For example, take a look at this design, it does make part of the type th=
e=20
> contents of the string. Google "A compile-time string library template wi=
th=20
> UDL operator templates" I dont know why I cannot access the link and=20
> downloads.
>
> This proposal allows: struct metaprogram<decltype("My metastring"S)>=20
>
> There is an alternative design keeping the size and contents both as a=20
> data member, without affecting the type. I wonder how that would work wit=
h=20
> strings as template parameters.
>

Not only does that proposal affect the type, each different string literal=
=20
is a different type.  This string class type contains the contents, as the=
=20
contents are a static member of the class.

class basic_string_literal {
    friend constexpr basic_string_literal operator""S<charT, HeadChar, Tail=
Chars...> ();

    public:
      static constexpr const charT data_[] =3D { HeadChar, TailChars..., '\=
0' };

=20

--=20

---=20
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 e=
mail 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-proposa=
ls/.

------=_Part_339_1497286203.1409764172534
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, September 3, 2014 3:28:21 AM UTC-4, german..=
..@personifyinc.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin:=
 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div =
dir=3D"ltr"><div>- Why, &lt;n&gt; is made part of the type. If you take a l=
ook closely, you will see that template&lt;const std::string_literal&lt;n&g=
t;&amp; s, typename T&gt; struct x=CD=BE needs the &lt;n&gt; when passing t=
he string for metaprogramming.</div><div><br></div><div>This means we must =
exactly match that &lt;n&gt; when metaprogramming. So my question was, if n=
 is not made part of the type, doesn't this make the design more flexible a=
nd equally powerful?</div></div></blockquote><div><br></div><div>Not making=
 it part of the type requires dynamic memory allocation. &nbsp;The entire p=
oint is to eliminate the dynamic memory allocation.</div><div>&nbsp;</div><=
blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bord=
er-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><span sty=
le=3D"font-size: 13px;">For example, take a look at this design, it does ma=
ke part of the type the contents of the string. Google "A compile-time stri=
ng library template with UDL operator templates" I dont know why I cannot a=
ccess the link and downloads.</span><br></div><div><br></div><div>This prop=
osal allows: struct metaprogram&lt;decltype("My metastring"S)&gt;&nbsp;</di=
v><div><br></div><div>There is an alternative design keeping the size and c=
ontents both as a data member, without affecting the type. I wonder how tha=
t would work with strings as template parameters.</div></div></blockquote><=
div><br></div><div>Not only does that proposal affect the type, each differ=
ent string literal is a different type. &nbsp;This string class type contai=
ns the contents, as the contents are a static member of the class.</div><di=
v><br></div><pre class=3D"example" style=3D"margin-left: 2em; color: rgb(0,=
 0, 0);"><code>class basic_string_literal {
    friend constexpr basic_string_literal operator""S&lt;charT, HeadChar, T=
ailChars...&gt; ();

    public:
      static constexpr const charT data_[] =3D { HeadChar, TailChars..., '\=
0' };
</code></pre><div>&nbsp;</div></div>

<p></p>

-- <br />
<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 <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 />
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_339_1497286203.1409764172534--

.


Author: germandiago@gmail.com
Date: Wed, 3 Sep 2014 10:32:16 -0700 (PDT)
Raw View
------=_Part_230_1093585287.1409765536664
Content-Type: text/plain; charset=UTF-8


>
>
> Not making it part of the type requires dynamic memory allocation.  The
> entire point is to eliminate the dynamic memory allocation.
>
>
I dont see how this holds true, but I may be missing something. The thing
is that if I do (note no <n> in const_string):

    constexpr const_string str = make_const_string("Hello, world");

Then, my  string is a pointer to an lvalue, since the literal string is
lvalue. I am now thinking of adding two strings, maybe this would not be
possible if you don't do the <n> part of the type available as a template
parameter.


> For example, take a look at this design, it does make part of the type the
>> contents of the string. Google "A compile-time string library template with
>> UDL operator templates" I dont know why I cannot access the link and
>> downloads.
>>
>> This proposal allows: struct metaprogram<decltype("My metastring"S)>
>>
>> There is an alternative design keeping the size and contents both as a
>> data member, without affecting the type. I wonder how that would work with
>> strings as template parameters.
>>
>
> Not only does that proposal affect the type, each different string literal
> is a different type.  This string class type contains the contents, as the
> contents are a static member of the class.
>
> All in all, it would be nice to pass the address of the string_literal<n>
without having to mention the n. I find this restrictive.

--

---
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_230_1093585287.1409765536664
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><div><br></div><div>Not making it part of the type requires dynamic mem=
ory allocation. &nbsp;The entire point is to eliminate the dynamic memory a=
llocation.</div><div>&nbsp;</div></div></blockquote><div>I dont see how thi=
s holds true, but I may be missing something. The thing is that if I do (no=
te no &lt;n&gt; in const_string):</div><div><br></div><div>&nbsp; &nbsp; co=
nstexpr const_string str =3D make_const_string("Hello, world");</div><div><=
br></div><div>Then, my &nbsp;string is a pointer to an lvalue, since the li=
teral string is lvalue. I am now thinking of adding two strings, maybe this=
 would not be possible if you don't do the &lt;n&gt; part of the type avail=
able as a template parameter.&nbsp;</div><div>&nbsp;</div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><blockquote class=3D"gmail_quo=
te" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-=
left:1ex"><div dir=3D"ltr"><div><span style=3D"font-size:13px">For example,=
 take a look at this design, it does make part of the type the contents of =
the string. Google "A compile-time string library template with UDL operato=
r templates" I dont know why I cannot access the link and downloads.</span>=
<br></div><div><br></div><div>This proposal allows: struct metaprogram&lt;d=
ecltype("My metastring"S)&gt;&nbsp;</div><div><br></div><div>There is an al=
ternative design keeping the size and contents both as a data member, witho=
ut affecting the type. I wonder how that would work with strings as templat=
e parameters.</div></div></blockquote><div><br></div><div>Not only does tha=
t proposal affect the type, each different string literal is a different ty=
pe. &nbsp;This string class type contains the contents, as the contents are=
 a static member of the class.</div><div><br></div></div></blockquote><div>=
All in all, it would be nice to pass the address of the string_literal&lt;n=
&gt; without having to mention the n. I find this restrictive.</div></div>

<p></p>

-- <br />
<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 <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 />
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_230_1093585287.1409765536664--

.


Author: Greg Marr <gregmmarr@gmail.com>
Date: Wed, 3 Sep 2014 10:38:09 -0700 (PDT)
Raw View
------=_Part_6564_870200267.1409765889837
Content-Type: text/plain; charset=UTF-8

On Wednesday, September 3, 2014 1:32:17 PM UTC-4, germa...@gmail.com wrote:
>
>
>> Not making it part of the type requires dynamic memory allocation.  The
>> entire point is to eliminate the dynamic memory allocation.
>>
>>
> I dont see how this holds true, but I may be missing something. The thing
> is that if I do (note no <n> in const_string):
>
>     constexpr const_string str = make_const_string("Hello, world");
>
> Then, my  string is a pointer to an lvalue, since the literal string is
> lvalue. I am now thinking of adding two strings, maybe this would not be
> possible if you don't do the <n> part of the type available as a template
> parameter.
>

How are you storing "Hello, world" if it's not part of the object?  If it
is part of the object, how are you getting the space in the object to store
the string?

Not only does that proposal affect the type, each different string literal
>> is a different type.  This string class type contains the contents, as the
>> contents are a static member of the class.
>>
>> All in all, it would be nice to pass the address of the string_literal<n>
> without having to mention the n. I find this restrictive.
>

You either have a type that can be referred to without the size, and thus
uses dynamic allocation (std::string), or you have a type without dynamic
allocation, and so it's fixed size (string_literal).  This is the same as
the comparison between std::vector and std::array.

--

---
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_6564_870200267.1409765889837
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, September 3, 2014 1:32:17 PM UTC-4, germa...=
@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;b=
order-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><br></div=
><div>Not making it part of the type requires dynamic memory allocation. &n=
bsp;The entire point is to eliminate the dynamic memory allocation.</div><d=
iv>&nbsp;</div></div></blockquote><div>I dont see how this holds true, but =
I may be missing something. The thing is that if I do (note no &lt;n&gt; in=
 const_string):</div><div><br></div><div>&nbsp; &nbsp; constexpr const_stri=
ng str =3D make_const_string("Hello, world");</div><div><br></div><div>Then=
, my &nbsp;string is a pointer to an lvalue, since the literal string is lv=
alue. I am now thinking of adding two strings, maybe this would not be poss=
ible if you don't do the &lt;n&gt; part of the type available as a template=
 parameter.&nbsp;</div></div></blockquote><div><br></div><div>How are you s=
toring "Hello, world" if it's not part of the object? &nbsp;If it is part o=
f the object, how are you getting the space in the object to store the stri=
ng?</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div d=
ir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:=
0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>No=
t only does that proposal affect the type, each different string literal is=
 a different type. &nbsp;This string class type contains the contents, as t=
he contents are a static member of the class.</div><div><br></div></div></b=
lockquote><div>All in all, it would be nice to pass the address of the stri=
ng_literal&lt;n&gt; without having to mention the n. I find this restrictiv=
e.</div></div></blockquote><div><br></div><div>You either have a type that =
can be referred to without the size, and thus uses dynamic allocation (std:=
:string), or you have a type without dynamic allocation, and so it's fixed =
size (string_literal). &nbsp;This is the same as the comparison between std=
::vector and std::array.</div><div><br></div></div>

<p></p>

-- <br />
<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 <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 />
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_6564_870200267.1409765889837--

.


Author: vadim.petrochenkov@gmail.com
Date: Wed, 3 Sep 2014 10:47:28 -0700 (PDT)
Raw View
------=_Part_1357_1426902109.1409766448681
Content-Type: text/plain; charset=UTF-8

>>constexpr const_string str = make_const_string("Hello, world");

Looks like string_literal_view: a non-owning reference to a string_literal
:)
Good thing is that string_view is already mostly constexpr.

On Wednesday, September 3, 2014 9:32:17 PM UTC+4, germa...@gmail.com wrote:
>
>
>> Not making it part of the type requires dynamic memory allocation.  The
>> entire point is to eliminate the dynamic memory allocation.
>>
>>
> I dont see how this holds true, but I may be missing something. The thing
> is that if I do (note no <n> in const_string):
>
>     constexpr const_string str = make_const_string("Hello, world");
>
> Then, my  string is a pointer to an lvalue, since the literal string is
> lvalue. I am now thinking of adding two strings, maybe this would not be
> possible if you don't do the <n> part of the type available as a template
> parameter.
>
>
>> For example, take a look at this design, it does make part of the type
>>> the contents of the string. Google "A compile-time string library template
>>> with UDL operator templates" I dont know why I cannot access the link and
>>> downloads.
>>>
>>> This proposal allows: struct metaprogram<decltype("My metastring"S)>
>>>
>>> There is an alternative design keeping the size and contents both as a
>>> data member, without affecting the type. I wonder how that would work with
>>> strings as template parameters.
>>>
>>
>> Not only does that proposal affect the type, each different string
>> literal is a different type.  This string class type contains the contents,
>> as the contents are a static member of the class.
>>
>> All in all, it would be nice to pass the address of the string_literal<n>
> without having to mention the n. I find this restrictive.
>

--

---
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_1357_1426902109.1409766448681
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">&gt;&gt;constexpr const_string str =3D make_const_string("=
Hello, world");<br><div><br></div><div>Looks like string_literal_view: a no=
n-owning reference to a string_literal :)</div><div>Good thing is that&nbsp=
;string_view is already mostly constexpr.</div><div><br></div>On Wednesday,=
 September 3, 2014 9:32:17 PM UTC+4, germa...@gmail.com wrote:<blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
 #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><blockquote class=3D"gmail=
_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div dir=3D"ltr"><div><br></div><div>Not making it part of th=
e type requires dynamic memory allocation. &nbsp;The entire point is to eli=
minate the dynamic memory allocation.</div><div>&nbsp;</div></div></blockqu=
ote><div>I dont see how this holds true, but I may be missing something. Th=
e thing is that if I do (note no &lt;n&gt; in const_string):</div><div><br>=
</div><div>&nbsp; &nbsp; constexpr const_string str =3D make_const_string("=
Hello, world");</div><div><br></div><div>Then, my &nbsp;string is a pointer=
 to an lvalue, since the literal string is lvalue. I am now thinking of add=
ing two strings, maybe this would not be possible if you don't do the &lt;n=
&gt; part of the type available as a template parameter.&nbsp;</div><div>&n=
bsp;</div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0=
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><span style=3D"font-s=
ize:13px">For example, take a look at this design, it does make part of the=
 type the contents of the string. Google "A compile-time string library tem=
plate with UDL operator templates" I dont know why I cannot access the link=
 and downloads.</span><br></div><div><br></div><div>This proposal allows: s=
truct metaprogram&lt;decltype("My metastring"S)&gt;&nbsp;</div><div><br></d=
iv><div>There is an alternative design keeping the size and contents both a=
s a data member, without affecting the type. I wonder how that would work w=
ith strings as template parameters.</div></div></blockquote><div><br></div>=
<div>Not only does that proposal affect the type, each different string lit=
eral is a different type. &nbsp;This string class type contains the content=
s, as the contents are a static member of the class.</div><div><br></div></=
div></blockquote><div>All in all, it would be nice to pass the address of t=
he string_literal&lt;n&gt; without having to mention the n. I find this res=
trictive.</div></div></blockquote></div>

<p></p>

-- <br />
<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 <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 />
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_1357_1426902109.1409766448681--

.