Topic: fixed_string
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 1 Oct 2014 19:56:42 -0700 (PDT)
Raw View
------=_Part_1167_1882071577.1412218602878
Content-Type: text/plain; charset=UTF-8
Because we just don't have enough string types. There are times when I've
wanted to have a fixed size string type. Essentially this would be like a
wrapper around char[N].
template <typename
size_t N,
class CharT,
class Traits = std::char_traits<CharT>
> class basic_fixed_string {
public:
//members...
private:
CharT _data[N];
}
template <size_t N> using fixed_string = basic_fixed_string<N,char>;
This is useful when you want to efficiently create a string from something
when you know the maximum length of the resulting string.
fixed_string<8> to_string(Date d); //returns "YYYYMMDD", which fits in a 64
bit register
template <size_t N> fixed_string<N> to_string(const bitset<N>& b); //Returns
a string of 1's and 0's
Some applications make use of fixed size strings. For example, in the
finance domain if you're working with bloomberg, bloomberg global ids which
are used to unique represent tradable securities are always 12 characters
long. Therefore we can represent them efficiently with a fixed_string of
size 12.
http://en.wikipedia.org/wiki/Bloomberg_Global_Identifier
using bbgid = fixed_string<12>;
These fixed size strings could also potentially be used for compile time
string processing.
template <size_t N, size_t M>
constexpr fixed_string<N + M> operator+(fixed_string<N> l, fixed_string<M> r
);
Can anyone think of a reason why something like this would be a bad idea?
--
---
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_1167_1882071577.1412218602878
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Because we just don't have enough string types. There are =
times when I've wanted to have a fixed size string type. Essentially this w=
ould be like a wrapper around char[N]. <div><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"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">template</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify"><</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
typename</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r> size_t N</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br> </span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">C=
harT</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nbs=
p; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Traits</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">char_traits</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify"><</span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">CharT</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">></span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> basic_fixed_str=
ing </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">public</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">//members...</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">private</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br> </span=
><span style=3D"color: #606;" class=3D"styled-by-prettify">CharT</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> _data</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">N</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">];</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">template</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">size_t N</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">></span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> fixed_string </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> basic_fixed_string</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">N</span><font color=3D"#666600">=
<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">>;</span></font></div></code>=
</div><br></div><div>This is useful when you want to efficiently create a s=
tring from something when you know the maximum length of the resulting stri=
ng.</div><div><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"><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">fixed_string</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span =
style=3D"color: #066;" class=3D"styled-by-prettify">8</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">></span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> to_string</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #606;" c=
lass=3D"styled-by-prettify">Date</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> d</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/returns "YYYYMMDD", which fits in a 64 bit register</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">size_t N</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> fixed_string</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">N</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> to_str=
ing</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> bitset</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">N</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">>&</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">);</span><font color=3D"#880000"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//Returns a string of 1's and 0's</sp=
an></font></div></code></div><div><br></div>Some applications make use of f=
ixed size strings. For example, in the finance domain if you're working wit=
h bloomberg, bloomberg global ids which are used to unique represent tradab=
le securities are always 12 characters long. Therefore we can represent the=
m efficiently with a fixed_string of size 12.</div><div><br></div><div>http=
://en.wikipedia.org/wiki/Bloomberg_Global_Identifier<br></div><div><br></di=
v><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 c=
lass=3D"prettyprint"><div class=3D"subprettyprint"><font color=3D"#660066">=
<span style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> bbgid </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> fixed_string</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">12</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">>;</span></font></div></code></div><br>=
These fixed size strings could also potentially be used for compile time st=
ring processing.</div><div><br></div><div><div class=3D"prettyprint" style=
=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 1=
87); word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">templ=
ate</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">size_t N</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> size_t M</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> fixed_string</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">N </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> M</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
></span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">operator</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">+(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">fixed_string</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">N</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> l</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> fixed_string</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><</span><font color=3D"#000000"><span style=3D"color: =
#000;" class=3D"styled-by-prettify">M</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> r</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">);</span></font></div></code></div></div><div><br></div><div>C=
an anyone think of a reason why something like this would be a bad idea?</d=
iv><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" 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_1167_1882071577.1412218602878--
.
Author: Matheus Izvekov <mizvekov@gmail.com>
Date: Wed, 1 Oct 2014 20:21:10 -0700 (PDT)
Raw View
------=_Part_6402_249648533.1412220070633
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 1, 2014 11:56:42 PM UTC-3, Matthew Fioravante wrote:
>
> Can anyone think of a reason why something like this would be a bad idea?
>
Well, it is weird that the size would be tied to the type, it would lead to
a lot of code being forced to be templated. A lot of string handling code
is quite complex.
Do you have examples of how do you plan to type erase them?
--
---
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_6402_249648533.1412220070633
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, October 1, 2014 11:56:42 PM UTC-3, Matthew F=
ioravante 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"lt=
r"><div></div><div>Can anyone think of a reason why something like this wou=
ld be a bad idea?</div></div></blockquote><div><br>Well, it is weird that t=
he size would be tied to the type, it would lead to a lot of code being for=
ced to be templated. A lot of string handling code is quite complex.<br>Do =
you have examples of how do you plan to type erase them?<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" 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_6402_249648533.1412220070633--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 1 Oct 2014 20:22:32 -0700 (PDT)
Raw View
------=_Part_4366_1258468521.1412220152086
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 1, 2014 11:21:10 PM UTC-4, Matheus Izvekov wrote:
>
>
> Do you have examples of how do you plan to type erase them?
>
In what sense? If you want to move to generic string processing you can use
string_view.
--
---
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_4366_1258468521.1412220152086
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, October 1, 2014 11:21:10 PM UTC-4, M=
atheus Izvekov wrote:<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>Do you have examples of how do you plan to type erase the=
m?<br></div></div></blockquote><div><br></div><div>In what sense? If you wa=
nt to move to generic string processing you can use string_view. </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" 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_4366_1258468521.1412220152086--
.
Author: Matheus Izvekov <mizvekov@gmail.com>
Date: Wed, 1 Oct 2014 20:29:42 -0700 (PDT)
Raw View
------=_Part_35_600305863.1412220582735
Content-Type: text/plain; charset=UTF-8
On Thursday, October 2, 2014 12:22:32 AM UTC-3, Matthew Fioravante wrote:
>
> In what sense? If you want to move to generic string processing you can
> use string_view.
>
Sorry, I am not entirely familiar with string_view yet, reading up on it
now.
But as I understand it, your fixed_string would not be zero terminated,
it's 'strlen' would be exactly the size embedded in the type, right?
Would working with a string_view necessitate a deep copy then?
--
---
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_35_600305863.1412220582735
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, October 2, 2014 12:22:32 AM UTC-3, Matthew Fi=
oravante 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></div><div>In what sense? If you want to move to generic string proc=
essing you can use string_view. </div></div></blockquote><div><br>Sorr=
y, I am not entirely familiar with string_view yet, reading up on it now.<b=
r><br>But as I understand it, your fixed_string would not be zero terminate=
d, it's 'strlen' would be exactly the size embedded in the type, right?<br>=
Would working with a string_view necessitate a deep copy then?<br></div></d=
iv>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <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_35_600305863.1412220582735--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 1 Oct 2014 20:37:25 -0700 (PDT)
Raw View
------=_Part_6410_1772004731.1412221045112
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 1, 2014 11:29:42 PM UTC-4, Matheus Izvekov wrote:
>
> On Thursday, October 2, 2014 12:22:32 AM UTC-3, Matthew Fioravante wrote:
>>
>> In what sense? If you want to move to generic string processing you can
>> use string_view.
>>
>
> Sorry, I am not entirely familiar with string_view yet, reading up on it
> now.
>
> But as I understand it, your fixed_string would not be zero terminated,
> it's 'strlen' would be exactly the size embedded in the type, right?
>
Yes that's right its not null terminated. It doesn't need to be because the
length is a compile time constant.
> Would working with a string_view necessitate a deep copy then?
>
No, string_view is also not null terminated. Once string_view becomes the
norm, we should have versions of all of the string facilities which accept
non-null terminated string_view. Therefore fixed_string will be
automatically supported as well.
Rant:
In my opinion null terminated strings are an abomination. You can't make
substrings of null terminated strings without a deep copy and operations
which work on the end of the string such as stripping trailing whitespace
become O(n) instead of O(1). Every time you pass a null terminated string
down the stack, strlen() has to be recomputed.
Has anyone used fgets() lately? This ridiculous function walks an internal
buffer to find a newline and copies it for you but doesn't tell you where
the newline was. You have to call strlen() and walk the string again!
How much energy do all of the servers in the world waste everyday computing
strlen() when they shouldn't need to?
--
---
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_6410_1772004731.1412221045112
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, October 1, 2014 11:29:42 PM UTC-4, M=
atheus Izvekov wrote:<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">On Thursday, October 2, 2014 12:22:32 AM UTC-3, Matthew Fioravante=
wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div></div>=
<div>In what sense? If you want to move to generic string processing you ca=
n use string_view. </div></div></blockquote><div><br>Sorry, I am not e=
ntirely familiar with string_view yet, reading up on it now.<br><br>But as =
I understand it, your fixed_string would not be zero terminated, it's 'strl=
en' would be exactly the size embedded in the type, right?<br></div></div><=
/blockquote><div><br></div><div>Yes that's right its not null terminated. I=
t doesn't need to be because the length is a compile time constant.</div><d=
iv> </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=
"><div>Would working with a string_view necessitate a deep copy then?<br></=
div></div></blockquote><div><br></div><div>No, string_view is also not null=
terminated. Once string_view becomes the norm, we should have versions of =
all of the string facilities which accept non-null terminated string_view. =
Therefore fixed_string will be automatically supported as well.</div><div><=
br></div><div><span style=3D"font-size: 13px;">Rant:</span></div><div><span=
style=3D"font-size: 13px;"><br></span></div><div><span style=3D"font-size:=
13px;">In my opinion null terminated strings are an abomination. You=
can't make substrings of null terminated strings without a deep copy and o=
perations which work on the end of the string such as stripping trailing wh=
itespace become O(n) instead of O(1). Every time you pass a null terminated=
string down the stack, strlen() has to be recomputed. </span></div><d=
iv><span style=3D"font-size: 13px;"><br></span></div><div>Has anyone used f=
gets() lately? This ridiculous function walks an internal buffer to find a =
newline and copies it for you but doesn't tell you where the newline was. Y=
ou have to call strlen() and walk the string again!</div><div><br></div><di=
v><div><span style=3D"font-size: 13px;">How much energy do all of the serve=
rs in the world waste everyday computing strlen() when they shouldn't need =
to?</span></div></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" 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_6410_1772004731.1412221045112--
.
Author: Matheus Izvekov <mizvekov@gmail.com>
Date: Wed, 1 Oct 2014 21:02:40 -0700 (PDT)
Raw View
------=_Part_6208_1438808313.1412222560906
Content-Type: text/plain; charset=UTF-8
On Thursday, October 2, 2014 12:37:25 AM UTC-3, Matthew Fioravante wrote:
>
> No, string_view is also not null terminated. Once string_view becomes the
> norm, we should have versions of all of the string facilities which accept
> non-null terminated string_view. Therefore fixed_string will be
> automatically supported as well.
>
Well that sounds good then.
There is probably nothing stopping one to use string_view in constexpr
context, so not a lot of operations would need to work on fixed_string
directly, and those that do, could still be small wrappers around their
string_view counterparts.
> Has anyone used fgets() lately? This ridiculous function walks an internal
> buffer to find a newline and copies it for you but doesn't tell you where
> the newline was. You have to call strlen() and walk the string again!
>
> How much energy do all of the servers in the world waste everyday
> computing strlen() when they shouldn't need to?
>
Agreed, but that can also be fixed by introducing a fgets alternative that
works on a mutable string_view. The string could still be null terminated,
but it could return the size as well.
This could be extended to a lot of string manipulators, many need to
compute the string size for their own operation, and they could just
additionally return it as well.
--
---
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_6208_1438808313.1412222560906
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, October 2, 2014 12:37:25 AM UTC-3, Matthew Fi=
oravante 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></div><div>No, string_view is also not null terminated. Once string_=
view becomes the norm, we should have versions of all of the string facilit=
ies which accept non-null terminated string_view. Therefore fixed_string wi=
ll be automatically supported as well.</div></div></blockquote><div><br>Wel=
l that sounds good then.<br>There is probably nothing stopping one to use s=
tring_view in constexpr context, so not a lot of operations would need to w=
ork on fixed_string directly, and those that do, could still be small wrapp=
ers around their string_view counterparts. <br> </div><blockquote clas=
s=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #c=
cc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><span style=3D"font-size=
:13px"></span></div><div>Has anyone used fgets() lately? This ridiculous fu=
nction walks an internal buffer to find a newline and copies it for you but=
doesn't tell you where the newline was. You have to call strlen() and walk=
the string again!</div><div><br></div><div><div><span style=3D"font-size:1=
3px">How much energy do all of the servers in the world waste everyday comp=
uting strlen() when they shouldn't need to?</span></div></div></div></block=
quote><div><br>Agreed, but that can also be fixed by introducing a fgets al=
ternative that works on a mutable string_view. The string could still be nu=
ll terminated, but it could return the size as well.<br><br>This could be e=
xtended to a lot of string manipulators, many need to compute the string si=
ze for their own operation, and they could just additionally return it as w=
ell.</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" 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_6208_1438808313.1412222560906--
.
Author: "Daniel Gutson" <danielgutson@gmail.com>
Date: Thu, 2 Oct 2014 04:50:24 +0000
Raw View
--part5562-boundary-1904933333-973325463
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
FWIW,
At the "C++ for embedded and real time applications" hopeful-WG we're loo=
king towards a more general solution: ability to have (global) const object=
s with nontrivial ctors in ROM, where static_string would be a particular c=
ase. There's an ongoing discussion about this internally, and surely it's s=
omething we'll discuss at urbana.
I beg you to either join this effort or wait what comes out of it before pu=
rsuing your approach (that requires to explicit the size). I'm more ambitio=
us, so I'd like e.g. static_set and all the other containers by empowering =
constexpr constructors. I don't intend to duplicate the internal discussion=
to this forum unless explicitly asked.
Feel free (you and antone welcome) to contact me to join the mailing list a=
nd continue the initiative there.
Thanks!
Daniel.
-----Original Message-----
From: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 1 Oct 2014 19:56:42=20
To: <std-proposals@isocpp.org>
Reply-To: std-proposals@isocpp.org
Subject: [std-proposals] fixed_string
Because we just don't have enough string types. There are times when I've=
=20
wanted to have a fixed size string type. Essentially this would be like a=
=20
wrapper around char[N].=20
template <typename
size_t N,
class CharT,
class Traits =3D std::char_traits<CharT>
> class basic_fixed_string {
public:
//members...
private:
CharT _data[N];
}
template <size_t N> using fixed_string =3D basic_fixed_string<N,char>;
This is useful when you want to efficiently create a string from something=
=20
when you know the maximum length of the resulting string.
fixed_string<8> to_string(Date d); //returns "YYYYMMDD", which fits in a 64=
=20
bit register
template <size_t N> fixed_string<N> to_string(const bitset<N>& b); //Return=
s=20
a string of 1's and 0's
Some applications make use of fixed size strings. For example, in the=20
finance domain if you're working with bloomberg, bloomberg global ids which=
=20
are used to unique represent tradable securities are always 12 characters=
=20
long. Therefore we can represent them efficiently with a fixed_string of=20
size 12.
http://en.wikipedia.org/wiki/Bloomberg_Global_Identifier
using bbgid =3D fixed_string<12>;
These fixed size strings could also potentially be used for compile time=20
string processing.
template <size_t N, size_t M>
constexpr fixed_string<N + M> operator+(fixed_string<N> l, fixed_string<M> =
r
);
Can anyone think of a reason why something like this would be a bad idea?
--=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/.
--=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/.
--part5562-boundary-1904933333-973325463
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><=
meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type"></h=
ead><body>FWIW,<br/><br/> At the "C++ for embedded and real time applicati=
ons" hopeful-WG we're looking towards a more general solution: ability to h=
ave (global) const objects with nontrivial ctors in ROM, where static_strin=
g would be a particular case. There's an ongoing discussion about this inte=
rnally, and surely it's something we'll discuss at urbana.<br/>I beg you to=
either join this effort or wait what comes out of it before pursuing your =
approach (that requires to explicit the size). I'm more ambitious, so I'd l=
ike e.g. static_set and all the other containers by empowering constexpr co=
nstructors. I don't intend to duplicate the internal discussion to this for=
um unless explicitly asked.<br/><br/>Feel free (you and antone welcome) to =
contact me to join the mailing list and continue the initiative there.<br/>=
<br/>Thanks!<br/><br/> Daniel.<hr/><div><b>From: </b> Matthew Fioravante &=
lt;fmatthew5876@gmail.com>
</div><div><b>Date: </b>Wed, 1 Oct 2014 19:56:42 -0700 (PDT)</div><div><b>T=
o: </b><std-proposals@isocpp.org></div><div><b>ReplyTo: </b> std-prop=
osals@isocpp.org
</div><div><b>Subject: </b>[std-proposals] fixed_string</div><div><br/></di=
v><div dir=3D"ltr">Because we just don't have enough string types. There ar=
e times when I've wanted to have a fixed size string type. Essentially this=
would be like a wrapper around char[N]. <div><br></div><div><div clas=
s=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border: 1p=
x solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettypr=
int"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">template</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify"><</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>typename</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br> size_t N</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br> </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
CharT</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nb=
sp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">class<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #606;" class=3D"styled-by-prettify">Traits</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">char_traits</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">CharT</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> basic_fixed_=
string </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">public</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br> </span=
><span style=3D"color: #800;" class=3D"styled-by-prettify">//members...</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">private</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br> </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">CharT</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> _data</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">N</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">];</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">template</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">size_t =
N</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: #008;" class=3D"styled-by-prettify">using</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> fixed_string </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> basic_fixed_string</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">N</span><font color=3D"#6666=
00"><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">>;</span></font></div></c=
ode></div><br></div><div>This is useful when you want to efficiently create=
a string from something when you know the maximum length of the resulting =
string.</div><div><br></div><div><div class=3D"prettyprint" style=3D"backgr=
ound-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">fixed_string</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><s=
pan style=3D"color: #066;" class=3D"styled-by-prettify">8</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> to_string</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Date</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> d</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>//returns "YYYYMMDD", which fits in a 64 bit register</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">template</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">size_t N</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> fixed_string</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">N</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>></span><span style=3D"color: #000;" class=3D"styled-by-prettify"> to_s=
tring</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> bitset</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">N</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">>&</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">);</span><font color=3D"#880000"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//Returns a string of 1's and 0's</sp=
an></font></div></code></div><div><br></div>Some applications make use of f=
ixed size strings. For example, in the finance domain if you're working wit=
h bloomberg, bloomberg global ids which are used to unique represent tradab=
le securities are always 12 characters long. Therefore we can represent the=
m efficiently with a fixed_string of size 12.</div><div><br></div><div>http=
://en.wikipedia.org/wiki/Bloomberg_Global_Identifier<br></div><div><br></di=
v><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 c=
lass=3D"prettyprint"><div class=3D"subprettyprint"><font color=3D"#660066">=
<span style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> bbgid </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> fixed_string</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">12</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">>;</span></font></div></code></div><br>=
These fixed size strings could also potentially be used for compile time st=
ring processing.</div><div><br></div><div><div class=3D"prettyprint" style=
=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 1=
87); word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">templ=
ate</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">size_t N</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> size_t M</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> fixed_string</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">N </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> M</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
></span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">operator</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">+(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">fixed_string</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">N</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> l</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> fixed_string</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><</span><font color=3D"#000000"><span style=3D"color: =
#000;" class=3D"styled-by-prettify">M</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> r</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">);</span></font></div></code></div></div><div><br></div><div>C=
an anyone think of a reason why something like this would be a bad idea?</d=
iv><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" 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 />
</body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <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 />
--part5562-boundary-1904933333-973325463--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 1 Oct 2014 22:01:32 -0700 (PDT)
Raw View
------=_Part_9_2071138637.1412226093463
Content-Type: text/plain; charset=UTF-8
On Thursday, October 2, 2014 12:50:29 AM UTC-4, dgutson wrote:
>
>
> I beg you to either join this effort or wait what comes out of it before
> pursuing your approach (that requires to explicit the size).
>
A user defined literal could avoid the size problem:
auto x = "abcdef"fs; //decltype(x) == fixed_string<6>.
Although I'm not sure its currently possible with the way user defined
literals are created now.
> I'm more ambitious, so I'd like e.g. static_set and all the other
> containers by empowering constexpr constructors.
>
The holy grail would be a compile time hash table with a perfect hashing
function.
--
---
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_9_2071138637.1412226093463
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, October 2, 2014 12:50:29 AM UTC-4, dg=
utson wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div><br>I beg you=
to either join this effort or wait what comes out of it before pursuing yo=
ur approach (that requires to explicit the size). </div></blockquote><div><=
br></div><div>A user defined literal could avoid the size problem:</div><di=
v><br></div><div>auto x =3D "abcdef"fs; //decltype(x) =3D=3D fixed_string&l=
t;6>.</div><div><br></div><div>Although I'm not sure its currently possi=
ble with the way user defined literals are created now.</div><div> </d=
iv><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;"><div>I'm more ambitious, so=
I'd like e.g. static_set and all the other containers by empowering conste=
xpr constructors. </div></blockquote><div><br></div><div>The holy grail wou=
ld be a compile time hash table with a perfect hashing function.</div><div>=
<br></div><div> </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" 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_9_2071138637.1412226093463--
.
Author: =?UTF-8?B?0JLQsNC00LjQvA==?= <vadim.petrochenkov@gmail.com>
Date: Thu, 2 Oct 2014 07:03:21 -0700 (PDT)
Raw View
------=_Part_5408_86053543.1412258601644
Content-Type: text/plain; charset=UTF-8
http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2014/n4121.pdf
?
On Thursday, October 2, 2014 6:56:42 AM UTC+4, Matthew Fioravante wrote:
>
> Because we just don't have enough string types. There are times when I've
> wanted to have a fixed size string type. Essentially this would be like a
> wrapper around char[N].
>
> template <typename
> size_t N,
> class CharT,
> class Traits = std::char_traits<CharT>
> > class basic_fixed_string {
> public:
> //members...
>
> private:
> CharT _data[N];
> }
>
> template <size_t N> using fixed_string = basic_fixed_string<N,char>;
>
> This is useful when you want to efficiently create a string from something
> when you know the maximum length of the resulting string.
>
> fixed_string<8> to_string(Date d); //returns "YYYYMMDD", which fits in a
> 64 bit register
> template <size_t N> fixed_string<N> to_string(const bitset<N>& b); //Returns
> a string of 1's and 0's
>
> Some applications make use of fixed size strings. For example, in the
> finance domain if you're working with bloomberg, bloomberg global ids which
> are used to unique represent tradable securities are always 12 characters
> long. Therefore we can represent them efficiently with a fixed_string of
> size 12.
>
> http://en.wikipedia.org/wiki/Bloomberg_Global_Identifier
>
> using bbgid = fixed_string<12>;
>
> These fixed size strings could also potentially be used for compile time
> string processing.
>
> template <size_t N, size_t M>
> constexpr fixed_string<N + M> operator+(fixed_string<N> l, fixed_string<M>
> r);
>
> Can anyone think of a reason why something like this would be a bad idea?
>
>
--
---
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_5408_86053543.1412258601644
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2014/n4=
121.pdf<br>?<br><br>On Thursday, October 2, 2014 6:56:42 AM UTC+4, Matthew =
Fioravante 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">Because we just don't have enough string types. There are times when I'=
ve wanted to have a fixed size string type. Essentially this would be like =
a wrapper around char[N]. <div><br></div><div><div style=3D"background=
-color:rgb(250,250,250);border:1px solid rgb(187,187,187);word-wrap:break-w=
ord"><code><div><span style=3D"color:#008">template</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660"><</span><span style=3D"colo=
r:#008">typename</span><span style=3D"color:#000"><br> size_t =
N</span><span style=3D"color:#660">,</span><span style=3D"color:#000"><br>&=
nbsp; </span><span style=3D"color:#008">class</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#606">CharT</span><span style=3D"co=
lor:#660">,</span><span style=3D"color:#000"><br> </span><span=
style=3D"color:#008">class</span><span style=3D"color:#000"> </span><span =
style=3D"color:#606">Traits</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">=3D</span><span style=3D"color:#000"> std</span><span =
style=3D"color:#660">::</span><span style=3D"color:#000">char_traits</span>=
<span style=3D"color:#660"><</span><span style=3D"color:#606">CharT</spa=
n><span style=3D"color:#660">></span><span style=3D"color:#000"><br>&nbs=
p;</span><span style=3D"color:#660">></span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">class</span><span style=3D"color:#000"> b=
asic_fixed_string </span><span style=3D"color:#660">{</span><span style=3D"=
color:#000"><br> </span><span style=3D"color:#008">public</span><span=
style=3D"color:#660">:</span><span style=3D"color:#000"><br> =
</span><span style=3D"color:#800">//members...</span><span style=3D"color:#=
000"><br><br> </span><span style=3D"color:#008">private</span><span s=
tyle=3D"color:#660">:</span><span style=3D"color:#000"><br> </=
span><span style=3D"color:#606">CharT</span><span style=3D"color:#000"> _da=
ta</span><span style=3D"color:#660">[</span><span style=3D"color:#000">N</s=
pan><span style=3D"color:#660">];</span><span style=3D"color:#000"><br></sp=
an><span style=3D"color:#660">}</span><span style=3D"color:#000"><br><br></=
span><span style=3D"color:#008">template</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660"><</span><span style=3D"color:#000">siz=
e_t N</span><span style=3D"color:#660">></span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">using</span><span style=3D"color:#000"=
> fixed_string </span><span style=3D"color:#660">=3D</span><span style=3D"c=
olor:#000"> basic_fixed_string</span><span style=3D"color:#660"><</span>=
<span style=3D"color:#000">N</span><font color=3D"#666600"><span style=3D"c=
olor:#660">,</span><span style=3D"color:#008">char</span><span style=3D"col=
or:#660">>;</span></font></div></code></div><br></div><div>This is usefu=
l when you want to efficiently create a string from something when you know=
the maximum length of the resulting string.</div><div><br></div><div><div =
style=3D"background-color:rgb(250,250,250);border:1px solid rgb(187,187,187=
);word-wrap:break-word"><code><div><span style=3D"color:#000">fixed_string<=
/span><span style=3D"color:#660"><</span><span style=3D"color:#066">8</s=
pan><span style=3D"color:#660">></span><span style=3D"color:#000"> to_st=
ring</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Da=
te</span><span style=3D"color:#000"> d</span><span style=3D"color:#660">);<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#800">//retur=
ns "YYYYMMDD", which fits in a 64 bit register</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#008">template</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660"><</span><span style=3D"colo=
r:#000">size_t N</span><span style=3D"color:#660">></span><span style=3D=
"color:#000"> fixed_string</span><span style=3D"color:#660"><</span><spa=
n style=3D"color:#000">N</span><span style=3D"color:#660">></span><span =
style=3D"color:#000"> to_string</span><span style=3D"color:#660">(</span><s=
pan style=3D"color:#008">const</span><span style=3D"color:#000"> bitset</sp=
an><span style=3D"color:#660"><</span><span style=3D"color:#000">N</span=
><span style=3D"color:#660">>&</span><span style=3D"color:#000"> b</=
span><span style=3D"color:#660">);</span><font color=3D"#880000"><span styl=
e=3D"color:#000"> </span><span style=3D"color:#800">//Returns a string of 1=
's and 0's</span></font></div></code></div><div><br></div>Some applications=
make use of fixed size strings. For example, in the finance domain if you'=
re working with bloomberg, bloomberg global ids which are used to unique re=
present tradable securities are always 12 characters long. Therefore we can=
represent them efficiently with a fixed_string of size 12.</div><div><br><=
/div><div><a href=3D"http://en.wikipedia.org/wiki/Bloomberg_Global_Identifi=
er" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url=
?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FBloomberg_Global_Identifier\46s=
a\75D\46sntz\0751\46usg\75AFQjCNF7mqt_8ug_jWTAUSa8QT8lzP7D_A';return true;"=
onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fen.wiki=
pedia.org%2Fwiki%2FBloomberg_Global_Identifier\46sa\75D\46sntz\0751\46usg\7=
5AFQjCNF7mqt_8ug_jWTAUSa8QT8lzP7D_A';return true;">http://en.wikipedia.org/=
wiki/<wbr>Bloomberg_Global_Identifier</a><br></div><div><br></div><div><div=
style=3D"background-color:rgb(250,250,250);border:1px solid rgb(187,187,18=
7);word-wrap:break-word"><code><div><font color=3D"#660066"><span style=3D"=
color:#008">using</span><span style=3D"color:#000"> bbgid </span><span styl=
e=3D"color:#660">=3D</span><span style=3D"color:#000"> fixed_string</span><=
span style=3D"color:#660"><</span><span style=3D"color:#066">12</span><s=
pan style=3D"color:#660">>;</span></font></div></code></div><br>These fi=
xed size strings could also potentially be used for compile time string pro=
cessing.</div><div><br></div><div><div style=3D"background-color:rgb(250,25=
0,250);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><div><=
span style=3D"color:#008">template</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660"><</span><span style=3D"color:#000">size_t N<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> size_t=
M</span><span style=3D"color:#660">></span><span style=3D"color:#000"><=
br></span><span style=3D"color:#008">constexpr</span><span style=3D"color:#=
000"> fixed_string</span><span style=3D"color:#660"><</span><span style=
=3D"color:#000">N </span><span style=3D"color:#660">+</span><span style=3D"=
color:#000"> M</span><span style=3D"color:#660">></span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#008">operator</span><span style=3D=
"color:#660">+(</span><span style=3D"color:#000">fixed_string</span><span s=
tyle=3D"color:#660"><</span><span style=3D"color:#000">N</span><span sty=
le=3D"color:#660">></span><span style=3D"color:#000"> l</span><span styl=
e=3D"color:#660">,</span><span style=3D"color:#000"> fixed_string</span><sp=
an style=3D"color:#660"><</span><font color=3D"#000000"><span style=3D"c=
olor:#000">M</span><span style=3D"color:#660">></span><span style=3D"col=
or:#000"> r</span><span style=3D"color:#660">);</span></font></div></code><=
/div></div><div><br></div><div>Can anyone think of a reason why something l=
ike this would be a bad idea?</div><div><br></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" 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_5408_86053543.1412258601644--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 2 Oct 2014 07:28:19 -0700 (PDT)
Raw View
------=_Part_694_720708428.1412260099882
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thursday, October 2, 2014 10:03:21 AM UTC-4, =D0=92=D0=B0=D0=B4=D0=B8=D0=
=BC wrote:
>
> http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2014/n4121.pdf
> ?
>
That looks like it does pretty much the same thing, except I would change a=
=20
few things:
- I would not use the name string_literal, as this has more uses than=20
just putting a better type than char[N+1] behind a string literal. I lis=
ted=20
a few in the original post.
- Get rid of the null terminator.=20
- The length is already implicit in the type.
- For dynamically allocated strings, adding a null byte is not a big=
=20
deal. For fixed size strings it gets in the way. For example if I hav=
e a=20
fixed size string of 8 bytes it fits exactly in a register, if I have=
1=20
more null byte it doesn't.=20
- With string_view, we will have full support for non-terminated=20
strings. We won't need the null terminator anymore for C compatibilit=
y.
=20
=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_694_720708428.1412260099882
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, October 2, 2014 10:03:21 AM UTC-4, =
=D0=92=D0=B0=D0=B4=D0=B8=D0=BC wrote:<blockquote class=3D"gmail_quote" styl=
e=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left:=
1ex;"><div dir=3D"ltr"><a href=3D"http://www.open-std.org/Jtc1/sc22/wg21/d=
ocs/papers/2014/n4121.pdf" target=3D"_blank" onmousedown=3D"this.href=3D'ht=
tp://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2FJtc1%2Fsc22%2Fw=
g21%2Fdocs%2Fpapers%2F2014%2Fn4121.pdf\46sa\75D\46sntz\0751\46usg\75AFQjCNE=
yYMeJU7JzaiAo2IEFGeodUTbnbw';return true;" onclick=3D"this.href=3D'http://w=
ww.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2FJtc1%2Fsc22%2Fwg21%2F=
docs%2Fpapers%2F2014%2Fn4121.pdf\46sa\75D\46sntz\0751\46usg\75AFQjCNEyYMeJU=
7JzaiAo2IEFGeodUTbnbw';return true;">http://www.open-std.org/Jtc1/<wbr>sc22=
/wg21/docs/papers/2014/<wbr>n4121.pdf</a><br>?<br></div></blockquote><div><=
br>That looks like it does pretty much the same thing, except I would chang=
e a few things:<br><code><br></code><ul><li><code>I would not use the name =
string_literal, as this has more uses than just putting a better type than =
char[N+1] behind a string literal. I listed a few in the original post.<br>=
</code></li><li><code>Get rid of the null terminator. </code></li><ul>=
<li><code>The length is already implicit in the type.</code><br></li><li><c=
ode>For dynamically allocated strings, adding a null byte is not a big deal=
.. For fixed size strings it gets in the way. For example if I have a fixed =
size string of 8 bytes it fits exactly in a register, if I have 1 more null=
byte it doesn't. <br></code></li><li><code>With string_view, we will have =
full support for non-terminated strings. We won't need the null terminator =
anymore for C compatibility.</code></li></ul></ul> <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" 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_694_720708428.1412260099882--
.
Author: Olaf van der Spek <olafvdspek@gmail.com>
Date: Thu, 2 Oct 2014 07:58:31 -0700 (PDT)
Raw View
------=_Part_709_693394721.1412261911175
Content-Type: text/plain; charset=UTF-8
On Thursday, October 2, 2014 6:50:29 AM UTC+2, dgutson wrote:
>
> At the "C++ for embedded and real time applications" hopeful-WG we're
> looking towards a more general solution: ability to have (global) const
> objects with nontrivial ctors in ROM, where static_string would be a
> particular case. There's an ongoing discussion about this internally, and
> surely it's something we'll discuss at urbana.
> I beg you to either join this effort or wait what comes out of it before
> pursuing your approach (that requires to explicit the size). I'm more
> ambitious, so I'd like e.g. static_set and all the other containers by
> empowering constexpr constructors. I don't intend to duplicate the internal
> discussion to this forum unless explicitly asked.
>
> Why would that require new types? Wouldn't it be better if const
std::string could be put in read-only memory?
--
---
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_709_693394721.1412261911175
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, October 2, 2014 6:50:29 AM UTC+2, dgutson wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;"><div>At the "C++ for embedd=
ed and real time applications" hopeful-WG we're looking towards a more gene=
ral solution: ability to have (global) const objects with nontrivial ctors =
in ROM, where static_string would be a particular case. There's an ongoing =
discussion about this internally, and surely it's something we'll discuss a=
t urbana.<br>I beg you to either join this effort or wait what comes out of=
it before pursuing your approach (that requires to explicit the size). I'm=
more ambitious, so I'd like e.g. static_set and all the other containers b=
y empowering constexpr constructors. I don't intend to duplicate the intern=
al discussion to this forum unless explicitly asked.<br><br></div></blockqu=
ote><div>Why would that require new types? Wouldn't it be better if const s=
td::string could be put in read-only memory? </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" 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_709_693394721.1412261911175--
.
Author: David Krauss <potswa@gmail.com>
Date: Thu, 2 Oct 2014 23:16:01 +0800
Raw View
--Apple-Mail=_A80DBEFF-FBA5-4F79-93A6-2F653F6C1754
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1
On 2014-10-02, at 10:58 PM, Olaf van der Spek <olafvdspek@gmail.com> wrote:
> Why would that require new types? Wouldn't it be better if const std::str=
ing could be put in read-only memory?=20
Predynamic storage duration would be killer for embedded. We should be 100%=
sure it's impossible before giving up on that route, and pursuing a dedica=
ted static_string.
Predynamic presents some serious challenges, but there's also a sizable des=
ign space to work within. If it works, it should be superior to anything el=
se. At best, it may be more like "turnkey" programming, or shipping the pro=
gram in a pre-started state, than "meta" programming. The former is one of =
the easiest paradigms whereas the latter is the most obtuse.
--=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/.
--Apple-Mail=_A80DBEFF-FBA5-4F79-93A6-2F653F6C1754
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;10–02, at 10:58 PM, Olaf van der Spek <<a href=3D"mailto:ola=
fvdspek@gmail.com">olafvdspek@gmail.com</a>> wrote:</div><br class=3D"Ap=
ple-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><div>Wh=
y would that require new types? Wouldn't it be better if const std::string =
could be put in read-only memory? </div></div></blockquote><div><br></=
div><div>Predynamic storage duration would be killer for embedded. We shoul=
d be 100% sure it’s impossible before giving up on that route, and pu=
rsuing a dedicated <font face=3D"Courier">static_string</font>.</div><div><=
br></div><div>Predynamic presents some serious challenges, but there’=
s also a sizable design space to work within. If it works, it should be sup=
erior to anything else. At best, it may be more like “turnkey” =
programming, or shipping the program in a pre-started state, than “me=
ta” programming. The former is one of the easiest paradigms whereas t=
he latter is the most obtuse.</div><div><br></div></div></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <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 />
--Apple-Mail=_A80DBEFF-FBA5-4F79-93A6-2F653F6C1754--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Thu, 02 Oct 2014 08:44:37 -0700
Raw View
On Thursday 02 October 2014 04:50:24 Daniel Gutson wrote:
> At the "C++ for embedded and real time applications" hopeful-WG we're
> looking towards a more general solution: ability to have (global) const
> objects with nontrivial ctors in ROM, where static_string would be a
> particular case. There's an ongoing discussion about this internally, and
> surely it's something we'll discuss at urbana.
Can you explain what you need that constexpr can't give you?
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--
---
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: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 2 Oct 2014 18:57:42 -0700 (PDT)
Raw View
------=_Part_4563_961026127.1412301463011
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thursday, October 2, 2014 11:16:15 AM UTC-4, David Krauss wrote:
>
>
> On 2014=E2=80=9310=E2=80=9302, at 10:58 PM, Olaf van der Spek <olafv...@g=
mail.com=20
> <javascript:>> wrote:
>
> Why would that require new types? Wouldn't it be better if const=20
> std::string could be put in read-only memory?=20
>
>
> Predynamic storage duration would be killer for embedded. We should be=20
> 100% sure it=E2=80=99s impossible before giving up on that route, and pur=
suing a=20
> dedicated static_string.
>
> Predynamic presents some serious challenges, but there=E2=80=99s also a s=
izable=20
> design space to work within. If it works, it should be superior to anythi=
ng=20
> else. At best, it may be more like =E2=80=9Cturnkey=E2=80=9D programming,=
or shipping the=20
> program in a pre-started state, than =E2=80=9Cmeta=E2=80=9D programming. =
The former is one=20
> of the easiest paradigms whereas the latter is the most obtuse.
>
This would be a great thing to have. Not only can it help with embedded=20
systems with tight memory constraints, it also can resolve race conditions=
=20
with things being initialized before main().
Maybe predynamic storage could be enabled with a special kind of constexpr=
=20
allocator?=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_4563_961026127.1412301463011
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, October 2, 2014 11:16:15 AM UTC-4, Da=
vid Krauss wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D=
"word-wrap:break-word"><br><div><div>On 2014=E2=80=9310=E2=80=9302, at 10:5=
8 PM, Olaf van der Spek <<a href=3D"javascript:" target=3D"_blank" gdf-o=
bfuscated-mailto=3D"OD0MM1Oqf6gJ" onmousedown=3D"this.href=3D'javascript:';=
return true;" onclick=3D"this.href=3D'javascript:';return true;">olafv...@g=
mail.com</a>> wrote:</div><br><blockquote type=3D"cite"><div dir=3D"ltr"=
><div>Why would that require new types? Wouldn't it be better if const std:=
:string could be put in read-only memory? </div></div></blockquote><di=
v><br></div><div>Predynamic storage duration would be killer for embedded. =
We should be 100% sure it=E2=80=99s impossible before giving up on that rou=
te, and pursuing a dedicated <font face=3D"Courier">static_string</font>.</=
div><div><br></div><div>Predynamic presents some serious challenges, but th=
ere=E2=80=99s also a sizable design space to work within. If it works, it s=
hould be superior to anything else. At best, it may be more like =E2=80=9Ct=
urnkey=E2=80=9D programming, or shipping the program in a pre-started state=
, than =E2=80=9Cmeta=E2=80=9D programming. The former is one of the easiest=
paradigms whereas the latter is the most obtuse.</div></div></div></blockq=
uote><div><br></div><div>This would be a great thing to have. Not only can =
it help with embedded systems with tight memory constraints, it also can re=
solve race conditions with things being initialized before main().</div><di=
v><br></div><div>Maybe predynamic storage could be enabled with a special k=
ind of constexpr allocator? </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" 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_4563_961026127.1412301463011--
.
Author: "dgutson ." <danielgutson@gmail.com>
Date: Fri, 3 Oct 2014 00:05:50 -0300
Raw View
On Thu, Oct 2, 2014 at 11:58 AM, Olaf van der Spek <olafvdspek@gmail.com> w=
rote:
> On Thursday, October 2, 2014 6:50:29 AM UTC+2, dgutson wrote:
>>
>> At the "C++ for embedded and real time applications" hopeful-WG we're
>> looking towards a more general solution: ability to have (global) const
>> objects with nontrivial ctors in ROM, where static_string would be a
>> particular case. There's an ongoing discussion about this internally, an=
d
>> surely it's something we'll discuss at urbana.
>> I beg you to either join this effort or wait what comes out of it before
>> pursuing your approach (that requires to explicit the size). I'm more
>> ambitious, so I'd like e.g. static_set and all the other containers by
>> empowering constexpr constructors. I don't intend to duplicate the inter=
nal
>> discussion to this forum unless explicitly asked.
>>
> Why would that require new types? Wouldn't it be better if const std::str=
ing
> could be put in read-only memory?
That could be ideal. But as far as my progress is on this matter, I
can't see that possible.
And, please note that this is not only about string, but all the
containers, including user-defined ones.
By reading the answers below, I saw that Andrew's predynamic storage
is somewhat in the same direction my line of thought.
But again, I don't want to duplicate all the discussion in the mailing
list and here. I welcome anyone eager to join.
Daniel.
--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?
--=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/.
.
Author: "dgutson ." <danielgutson@gmail.com>
Date: Fri, 3 Oct 2014 00:08:31 -0300
Raw View
On Thu, Oct 2, 2014 at 12:16 PM, David Krauss <potswa@gmail.com> wrote:
>
> On 2014=E2=80=9310=E2=80=9302, at 10:58 PM, Olaf van der Spek <olafvdspek=
@gmail.com> wrote:
>
> Why would that require new types? Wouldn't it be better if const std::str=
ing
> could be put in read-only memory?
>
>
> Predynamic storage duration would be killer for embedded. We should be 10=
0%
> sure it=E2=80=99s impossible before giving up on that route, and pursuing=
a
> dedicated static_string.
>
> Predynamic presents some serious challenges, but there=E2=80=99s also a s=
izable
> design space to work within. If it works, it should be superior to anythi=
ng
> else. At best, it may be more like =E2=80=9Cturnkey=E2=80=9D programming,=
or shipping the
> program in a pre-started state, than =E2=80=9Cmeta=E2=80=9D programming. =
The former is one
> of the easiest paradigms whereas the latter is the most obtuse.
Thanks for bringing this, I wasn't familiar with the predynamic
storage idea, which is somewhat in the same direction my line of
thought: compile-time allocation and compile-time pointers.
Despite I don't want to get deeper here, I add as a note that having
such predynamic storage (and declaring it const) will get into ROM.
>
> --
>
> ---
> 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/.
--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?
--=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/.
.
Author: "dgutson ." <danielgutson@gmail.com>
Date: Fri, 3 Oct 2014 00:09:02 -0300
Raw View
On Thu, Oct 2, 2014 at 10:57 PM, Matthew Fioravante
<fmatthew5876@gmail.com> wrote:
>
>
> On Thursday, October 2, 2014 11:16:15 AM UTC-4, David Krauss wrote:
>>
>>
>> On 2014=E2=80=9310=E2=80=9302, at 10:58 PM, Olaf van der Spek <olafv...@=
gmail.com> wrote:
>>
>> Why would that require new types? Wouldn't it be better if const
>> std::string could be put in read-only memory?
>>
>>
>> Predynamic storage duration would be killer for embedded. We should be
>> 100% sure it=E2=80=99s impossible before giving up on that route, and pu=
rsuing a
>> dedicated static_string.
>>
>> Predynamic presents some serious challenges, but there=E2=80=99s also a =
sizable
>> design space to work within. If it works, it should be superior to anyth=
ing
>> else. At best, it may be more like =E2=80=9Cturnkey=E2=80=9D programming=
, or shipping the
>> program in a pre-started state, than =E2=80=9Cmeta=E2=80=9D programming.=
The former is one
>> of the easiest paradigms whereas the latter is the most obtuse.
>
>
> This would be a great thing to have. Not only can it help with embedded
> systems with tight memory constraints, it also can resolve race condition=
s
> with things being initialized before main().
>
> Maybe predynamic storage could be enabled with a special kind of constexp=
r
> allocator?
I'm in that direction.
>
> --
>
> ---
> 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/.
--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?
--=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/.
.
Author: "dgutson ." <danielgutson@gmail.com>
Date: Fri, 3 Oct 2014 00:13:01 -0300
Raw View
On Thu, Oct 2, 2014 at 12:44 PM, Thiago Macieira <thiago@macieira.org> wrot=
e:
> On Thursday 02 October 2014 04:50:24 Daniel Gutson wrote:
>> At the "C++ for embedded and real time applications" hopeful-WG we're
>> looking towards a more general solution: ability to have (global) const
>> objects with nontrivial ctors in ROM, where static_string would be a
>> particular case. There's an ongoing discussion about this internally, an=
d
>> surely it's something we'll discuss at urbana.
>
> Can you explain what you need that constexpr can't give you?
Not accurately, seems it's too early in the research and exploring state.
Superficially, seems to be: compile-time allocation (which seems very
similar to predynamic storage), compile-time pointers (or pointers
arithmetic), and writeable const attributes during constexpr
construction.
Please don't challenge these assertions now :) but instead help in
this very early brainstorming by joining the mailing list.
Daniel.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel Open Source Technology Center
> PGP/GPG: 0x6EF45358; fingerprint:
> E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
>
> --
>
> ---
> 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-propo=
sals/.
--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?
--=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/.
.