Topic: std::integer_of_size<N> in type_traits


Author: Evan Teran <evan.teran@gmail.com>
Date: Wed, 23 Apr 2014 13:19:50 -0700 (PDT)
Raw View
------=_Part_588_23354481.1398284390338
Content-Type: text/plain; charset=UTF-8


I would love to see <type_traits> have a template which looks like this:

template <size_t N>
struct std::integer_of_size<N> {
 typedef /* implementation defined */ type; // in case the implementation
doesn't want to care about signed-ness like for: char, signed char, unsigned
char
 typedef /* implementation defined */ signed_type;
 typedef /* implementation defined */ unsigned_type;
};


which for a given size N will give an easy method for getting a type of that size. I've written this before and it has proven useful time and time again. It would be great if it were part of the standard.


Example usage would of course look like this:


typedef typename std::integer_of_size<64>::unsigned_type u64;
u64 x = 1234;
static_assert(sizeof(u64) == sizeof(uint64_t), "Broken integer_of_size"); //
this should always be true


I forget if that "typename" would be necessary in this particular example.


Strikes me as an easy and simple addition.

--

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

<div dir=3D"ltr"><font face=3D"arial, sans-serif" size=3D"2"><br></font><di=
v><font face=3D"arial, sans-serif" size=3D"2">I would love to see &lt;type_=
traits&gt; have a template which looks like this:</font></div><div><font fa=
ce=3D"arial, sans-serif" size=3D"2"><br></font></div><div><div class=3D"pre=
ttyprint" style=3D"background-color: rgb(250, 250, 250); border: 1px solid =
rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint"><di=
v class=3D"subprettyprint"><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">&gt;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span st=
yle=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">integer_of_size</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">N</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&gt;</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=
"><br>&nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">typedef</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #800;" class=3D"styled-by-prettify">/* impleme=
ntation defined */</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> type</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">// in case the =
implementation doesn't want to care about signed-ness like for: char, signe=
d char, un</span><span style=3D"color: #800;" class=3D"styled-by-prettify">=
signed char</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>&nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>typedef</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">/* implemen=
tation defined */</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> signed_type</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>&nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
typedef</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">/* implement=
ation defined */</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> unsigned_type</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"styled-by-prettify">};</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></=
div></code></div><pre style=3D"color: rgb(0, 0, 0);"><code><font face=3D"ar=
ial, sans-serif" size=3D"2"><br></font></code></pre><pre style=3D"color: rg=
b(0, 0, 0);"><span style=3D"font-family: arial, sans-serif; font-size: smal=
l;">which for a given size N will give an easy method for getting a type of=
 that size. </span><span style=3D"font-family: arial, sans-serif; font-size=
: small;">I've written this before and it has proven useful time and time a=
gain. It would be great if it were part of the standard.</span><br></pre><p=
re style=3D"color: rgb(0, 0, 0);"><span style=3D"font-family: arial, sans-s=
erif; font-size: small;"><br></span></pre><pre style=3D"color: rgb(0, 0, 0)=
;"><span style=3D"font-family: arial, sans-serif; font-size: small;">Exampl=
e usage would of course look like this:</span></pre><pre style=3D"color: rg=
b(0, 0, 0);"><span style=3D"font-family: arial, sans-serif; font-size: smal=
l;"><br></span></pre><div class=3D"prettyprint" style=3D"background-color: =
rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: break-=
word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">typedef</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">typename</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">integer_of_size</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">64</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&gt;::</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">unsigned_type u64</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>u64 x </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">1234</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">static_assert</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">sizeof</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">u64</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">sizeof<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">uint64_t</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">),</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">"Broken integer_of_size"</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
800;" class=3D"styled-by-prettify">// this should always be true</span></di=
v></code></div><pre style=3D"color: rgb(0, 0, 0);"><span style=3D"font-fami=
ly: arial, sans-serif; font-size: small;"><br></span></pre><pre style=3D"co=
lor: rgb(0, 0, 0);"><span style=3D"font-family: arial, sans-serif; font-siz=
e: small;">I forget if that "typename" would be necessary in this particula=
r example.</span></pre><pre style=3D"color: rgb(0, 0, 0);"><span style=3D"f=
ont-family: arial, sans-serif; font-size: small;"><br></span></pre><pre sty=
le=3D"color: rgb(0, 0, 0);"><span style=3D"font-family: arial, sans-serif; =
font-size: small;">Strikes me as an easy and simple addition.</span></pre><=
/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_588_23354481.1398284390338--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 23 Apr 2014 23:24:15 +0300
Raw View
On 23 April 2014 23:19, Evan Teran <evan.teran@gmail.com> wrote:
> I would love to see <type_traits> have a template which looks like this:
> template <size_t N>
> struct std::integer_of_size<N> {
>  typedef /* implementation defined */ type; // in case the implementation
> doesn't want to care about signed-ness like for: char, signed char, unsigned
> char
>  typedef /* implementation defined */ signed_type;
>  typedef /* implementation defined */ unsigned_type;
> };
> which for a given size N will give an easy method for getting a type of that
> size. I've written this before and it has proven useful time and time again.
> It would be great if it were part of the standard.
> Example usage would of course look like this:
> typedef typename std::integer_of_size<64>::unsigned_type u64;
> u64 x = 1234;
> static_assert(sizeof(u64) == sizeof(uint64_t), "Broken integer_of_size"); //
> this should always be true
> I forget if that "typename" would be necessary in this particular example.
> Strikes me as an easy and simple addition.


I doubt it's so simple. Types like uint8_t are optional because some
implementations
can't support them (they have eg. 24-bit chars). So what should such platforms
do when encountering integer_of_size<8>?

--

---
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: Nevin Liber <nevin@eviloverlord.com>
Date: Wed, 23 Apr 2014 15:45:24 -0500
Raw View
--047d7b6dc60833ab7904f7bbd207
Content-Type: text/plain; charset=UTF-8

On 23 April 2014 15:19, Evan Teran <evan.teran@gmail.com> wrote:

>
> I would love to see <type_traits> have a template which looks like this:
>
> template <size_t N>
> struct std::integer_of_size<N> {
>  typedef /* implementation defined */ type; // in case the implementation
> doesn't want to care about signed-ness like for: char, signed char, unsigned
> char
>  typedef /* implementation defined */ signed_type;
>  typedef /* implementation defined */ unsigned_type;
> };
>
>
> which for a given size N will give an easy method for getting a type of that size. I've written this before and it has proven useful time and time again. It would be great if it were part of the standard.
>
>
If you need something like this, it isn't that hard to do yourself by
walking a type list (and doing it yourself gets around the thorny issues
that Ville brings up).
--
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404

--

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

--047d7b6dc60833ab7904f7bbd207
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On 23 April 2014 15:19, Evan Teran <span dir=3D"ltr">&lt;<=
a href=3D"mailto:evan.teran@gmail.com" target=3D"_blank">evan.teran@gmail.c=
om</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_=
quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-=
left:1px #ccc solid;padding-left:1ex">

<div dir=3D"ltr"><font face=3D"arial, sans-serif"><br></font><div><font fac=
e=3D"arial, sans-serif">I would love to see &lt;type_traits&gt; have a temp=
late which looks like this:</font></div><div><font face=3D"arial, sans-seri=
f"><br>

</font></div><div><div style=3D"background-color:rgb(250,250,250);border:1p=
x solid rgb(187,187,187);word-wrap:break-word"><code><div><span style=3D"co=
lor:#008">template</span><span style> </span><span style=3D"color:#660">&lt=
;</span><span style>size_t N</span><span style=3D"color:#660">&gt;</span><s=
pan style><br>

</span><span style=3D"color:#008">struct</span><span style> std</span><span=
 style=3D"color:#660">::</span><span style>integer_of_size</span><span styl=
e=3D"color:#660">&lt;</span><span style>N</span><span style=3D"color:#660">=
&gt;</span><span style> </span><span style=3D"color:#660">{</span><span sty=
le><br>

=C2=A0</span><span style=3D"color:#008">typedef</span><span style> </span><=
span style=3D"color:#800">/* implementation defined */</span><span style> t=
ype</span><span style=3D"color:#660">;</span><span style> </span><span styl=
e=3D"color:#800">// in case the implementation doesn&#39;t want to care abo=
ut signed-ness like for: char, signed char, un</span><span style=3D"color:#=
800">signed char</span><span style><br>

=C2=A0</span><span style=3D"color:#008">typedef</span><span style> </span><=
span style=3D"color:#800">/* implementation defined */</span><span style> s=
igned_type</span><span style=3D"color:#660">;</span><span style><br>=C2=A0<=
/span><span style=3D"color:#008">typedef</span><span style> </span><span st=
yle=3D"color:#800">/* implementation defined */</span><span style> unsigned=
_type</span><span style=3D"color:#660">;</span><span style><br>

</span><span style=3D"color:#660">};</span><span style><br></span></div></c=
ode></div><pre style><code><font face=3D"arial, sans-serif"><br></font></co=
de></pre><pre style><span style=3D"font-family:arial,sans-serif;font-size:s=
mall">which for a given size N will give an easy method for getting a type =
of that size. </span><span style=3D"font-family:arial,sans-serif;font-size:=
small">I&#39;ve written this before and it has proven useful time and time =
again. It would be great if it were part of the standard.</span></pre>

</div></div></blockquote><div><br></div><div>If you need something like thi=
s, it isn&#39;t that hard to do yourself by walking a type list (and doing =
it yourself gets around the thorny issues that Ville brings up).</div>
</div>
-- <br>=C2=A0Nevin &quot;:-)&quot; Liber=C2=A0 &lt;mailto:<a href=3D"mailto=
:nevin@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>&gt;=
=C2=A0 (847) 691-1404
</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 />

--047d7b6dc60833ab7904f7bbd207--

.


Author: Evan Teran <evan.teran@gmail.com>
Date: Wed, 23 Apr 2014 14:00:47 -0700 (PDT)
Raw View
------=_Part_6446_22800120.1398286847361
Content-Type: text/plain; charset=UTF-8

@Ville. For those they simply wouldn't be specialized and result in compile
time error. I think that's a reasonable enough and par for the course for
template when dealing with things that may or may not be there. This struct
could easily also have an "is_specialized" member like
std::numeric_limits<T> currently has.

@Nevin. Yes it is easy enough, I've done it before. It just feels like
something that would nice to have "just there". I've written code a few
times that wants to know the type for a given size specified at compile
time. Personally, I don't really find "It's easy enough to implement
yourself" to be a satisfactory answer for why something isn't in the
standard. But I understand where you are coming from.

Anything simple and useful seems like a good candidate for inclusion.

On Wednesday, April 23, 2014 4:45:24 PM UTC-4, Nevin ":-)" Liber wrote:
>
> On 23 April 2014 15:19, Evan Teran <evan....@gmail.com <javascript:>>wrote:
>
>>
>> I would love to see <type_traits> have a template which looks like this:
>>
>> template <size_t N>
>> struct std::integer_of_size<N> {
>>  typedef /* implementation defined */ type; // in case the
>> implementation doesn't want to care about signed-ness like for: char,
>> signed char, unsigned char
>>  typedef /* implementation defined */ signed_type;
>>  typedef /* implementation defined */ unsigned_type;
>> };
>>
>>
>> which for a given size N will give an easy method for getting a type of that size. I've written this before and it has proven useful time and time again. It would be great if it were part of the standard.
>>
>>
> If you need something like this, it isn't that hard to do yourself by
> walking a type list (and doing it yourself gets around the thorny issues
> that Ville brings up).
>  --
>  Nevin ":-)" Liber  <mailto:ne...@eviloverlord.com <javascript:>>  (847)
> 691-1404
>

--

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

<div dir=3D"ltr">@Ville. For those they simply wouldn't be specialized and =
result in compile time error. I think that's a reasonable enough and par fo=
r the course for template when dealing with things that may or may not be t=
here. This struct could easily also have an "is_specialized" member like st=
d::numeric_limits&lt;T&gt; currently has.<div><br></div><div>@Nevin. Yes it=
 is easy enough, I've done it before. It just feels like something that wou=
ld nice to have "just there". I've written code a few times that wants to k=
now the type for a given size specified at compile time. Personally, I don'=
t really find "It's easy enough to implement yourself" to be a satisfactory=
 answer for why something isn't in the standard. But I understand where you=
 are coming from.</div><div><br></div><div>Anything simple and useful seems=
 like a good candidate for inclusion.<br><br>On Wednesday, April 23, 2014 4=
:45:24 PM UTC-4, Nevin ":-)" Liber wrote:<blockquote class=3D"gmail_quote" =
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-l=
eft: 1ex;"><div dir=3D"ltr">On 23 April 2014 15:19, Evan Teran <span dir=3D=
"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=
=3D"UX0YekSAZ94J" onmousedown=3D"this.href=3D'javascript:';return true;" on=
click=3D"this.href=3D'javascript:';return true;">evan....@gmail.com</a>&gt;=
</span> wrote:<br><div><div class=3D"gmail_quote"><blockquote class=3D"gmai=
l_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left=
:1ex">

<div dir=3D"ltr"><font face=3D"arial, sans-serif"><br></font><div><font fac=
e=3D"arial, sans-serif">I would love to see &lt;type_traits&gt; have a temp=
late which looks like this:</font></div><div><font face=3D"arial, sans-seri=
f"><br>

</font></div><div><div style=3D"background-color:rgb(250,250,250);border:1p=
x solid rgb(187,187,187);word-wrap:break-word"><code><div><span style=3D"co=
lor:#008">template</span><span> </span><span style=3D"color:#660">&lt;</spa=
n><span>size_t N</span><span style=3D"color:#660">&gt;</span><span><br>

</span><span style=3D"color:#008">struct</span><span> std</span><span style=
=3D"color:#660">::</span><span>integer_of_size</span><span style=3D"color:#=
660">&lt;</span><span>N</span><span style=3D"color:#660">&gt;</span><span> =
</span><span style=3D"color:#660">{</span><span><br>

&nbsp;</span><span style=3D"color:#008">typedef</span><span> </span><span s=
tyle=3D"color:#800">/* implementation defined */</span><span> type</span><s=
pan style=3D"color:#660">;</span><span> </span><span style=3D"color:#800">/=
/ in case the implementation doesn't want to care about signed-ness like fo=
r: char, signed char, un</span><span style=3D"color:#800">signed char</span=
><span><br>

&nbsp;</span><span style=3D"color:#008">typedef</span><span> </span><span s=
tyle=3D"color:#800">/* implementation defined */</span><span> signed_type</=
span><span style=3D"color:#660">;</span><span><br>&nbsp;</span><span style=
=3D"color:#008">typedef</span><span> </span><span style=3D"color:#800">/* i=
mplementation defined */</span><span> unsigned_type</span><span style=3D"co=
lor:#660">;</span><span><br>

</span><span style=3D"color:#660">};</span><span><br></span></div></code></=
div><pre><code><font face=3D"arial, sans-serif"><br></font></code></pre><pr=
e><span style=3D"font-family:arial,sans-serif;font-size:small">which for a =
given size N will give an easy method for getting a type of that size. </sp=
an><span style=3D"font-family:arial,sans-serif;font-size:small">I've writte=
n this before and it has proven useful time and time again. It would be gre=
at if it were part of the standard.</span></pre>

</div></div></blockquote><div><br></div><div>If you need something like thi=
s, it isn't that hard to do yourself by walking a type list (and doing it y=
ourself gets around the thorny issues that Ville brings up).</div>
</div>
-- <br>&nbsp;Nevin ":-)" Liber&nbsp; &lt;mailto:<a href=3D"javascript:" tar=
get=3D"_blank" gdf-obfuscated-mailto=3D"UX0YekSAZ94J" onmousedown=3D"this.h=
ref=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';retu=
rn true;">ne...@eviloverlord.com</a><wbr>&gt;&nbsp; (847) 691-1404
</div></div>
</blockquote></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_6446_22800120.1398286847361--

.


Author: =?UTF-8?Q?R=C3=B3bert_D=C3=A1vid?= <lrdxgm@gmail.com>
Date: Thu, 24 Apr 2014 17:40:16 -0700 (PDT)
Raw View
------=_Part_133_16788605.1398386416494
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



2014. =C3=A1prilis 23., szerda 22:24:15 UTC+2 id=C5=91pontban Ville Voutila=
inen a=20
k=C3=B6vetkez=C5=91t =C3=ADrta:
>
> On 23 April 2014 23:19, Evan Teran <evan....@gmail.com <javascript:>>=20
> wrote:=20
> > I would love to see <type_traits> have a template which looks like this=
:=20
> > template <size_t N>=20
> > struct std::integer_of_size<N> {=20
> >  typedef /* implementation defined */ type; // in case the=20
> implementation=20
> > doesn't want to care about signed-ness like for: char, signed char,=20
> unsigned=20
> > char=20
> >  typedef /* implementation defined */ signed_type;=20
> >  typedef /* implementation defined */ unsigned_type;=20
> > };=20
> > which for a given size N will give an easy method for getting a type of=
=20
> that=20
> > size. I've written this before and it has proven useful time and time=
=20
> again.=20
> > It would be great if it were part of the standard.=20
> > Example usage would of course look like this:=20
> > typedef typename std::integer_of_size<64>::unsigned_type u64;=20
> > u64 x =3D 1234;=20
> > static_assert(sizeof(u64) =3D=3D sizeof(uint64_t), "Broken=20
> integer_of_size"); //=20
> > this should always be true=20
> > I forget if that "typename" would be necessary in this particular=20
> example.=20
> > Strikes me as an easy and simple addition.=20
>
>
> I doubt it's so simple. Types like uint8_t are optional because some=20
> implementations=20
> can't support them (they have eg. 24-bit chars). So what should such=20
> platforms=20
> do when encountering integer_of_size<8>?=20
>

What does int8_t do on that platform? It simply does not compile (I'd=20
guess, with an "undefined type" error). I'd expect integer_of_size<8> do do=
=20
the same (and in the meanwhile can provide a better error message as=20
"Sorry, this platform does not support "+to_string(N)+"-bit integers" with=
=20
a static_assert.)

Also, the "proposal" can be extended with fast_integer<N>,=20
integer_least<N>, meaning (u)int_fastN_t and (u)int_leastN_t

Regards,
Robert

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

<div dir=3D"ltr"><br><br>2014. =C3=A1prilis 23., szerda 22:24:15 UTC+2 id=
=C5=91pontban Ville Voutilainen a k=C3=B6vetkez=C5=91t =C3=ADrta:<blockquot=
e class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: =
1px #ccc solid;padding-left: 1ex;">On 23 April 2014 23:19, Evan Teran &lt;<=
a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"4KfF2n6OJ=
c4J" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this=
..href=3D'javascript:';return true;">evan....@gmail.com</a>&gt; wrote:
<br>&gt; I would love to see &lt;type_traits&gt; have a template which look=
s like this:
<br>&gt; template &lt;size_t N&gt;
<br>&gt; struct std::integer_of_size&lt;N&gt; {
<br>&gt; &nbsp;typedef /* implementation defined */ type; // in case the im=
plementation
<br>&gt; doesn't want to care about signed-ness like for: char, signed char=
, unsigned
<br>&gt; char
<br>&gt; &nbsp;typedef /* implementation defined */ signed_type;
<br>&gt; &nbsp;typedef /* implementation defined */ unsigned_type;
<br>&gt; };
<br>&gt; which for a given size N will give an easy method for getting a ty=
pe of that
<br>&gt; size. I've written this before and it has proven useful time and t=
ime again.
<br>&gt; It would be great if it were part of the standard.
<br>&gt; Example usage would of course look like this:
<br>&gt; typedef typename std::integer_of_size&lt;64&gt;::<wbr>unsigned_typ=
e u64;
<br>&gt; u64 x =3D 1234;
<br>&gt; static_assert(sizeof(u64) =3D=3D sizeof(uint64_t), "Broken integer=
_of_size"); //
<br>&gt; this should always be true
<br>&gt; I forget if that "typename" would be necessary in this particular =
example.
<br>&gt; Strikes me as an easy and simple addition.
<br>
<br>
<br>I doubt it's so simple. Types like uint8_t are optional because some
<br>implementations
<br>can't support them (they have eg. 24-bit chars). So what should such pl=
atforms
<br>do when encountering integer_of_size&lt;8&gt;?
<br></blockquote><div><br>What does int8_t do on that platform? It simply d=
oes not compile (I'd guess, with an "undefined type" error). I'd expect int=
eger_of_size&lt;8&gt; do do the same (and in the meanwhile can provide a be=
tter error message as "Sorry, this platform does not support "+to_string(N)=
+"-bit integers" with a static_assert.)<br><br>Also, the "proposal" can be =
extended with fast_integer&lt;N&gt;, integer_least&lt;N&gt;, meaning (u)int=
_fastN_t and (u)int_leastN_t<br><br>Regards,<br>Robert<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_133_16788605.1398386416494--

.


Author: Evan Teran <evan.teran@gmail.com>
Date: Fri, 25 Apr 2014 06:45:30 -0700 (PDT)
Raw View
------=_Part_72_6399838.1398433530565
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

@R=C3=B3bert, That's precsely what I had in mind. Also I do like your idea =
of=20
extending this to cover the fast/least variants as well. Though I think=20
we'd want to have a more consistent naming convention. Perhaps:

std::integer<N>
std::fast_integer<N>
std::least_integer<N>



On Thursday, April 24, 2014 8:40:16 PM UTC-4, R=C3=B3bert D=C3=A1vid wrote:
>
>
>
> 2014. =C3=A1prilis 23., szerda 22:24:15 UTC+2 id=C5=91pontban Ville Vouti=
lainen a=20
> k=C3=B6vetkez=C5=91t =C3=ADrta:
>>
>> On 23 April 2014 23:19, Evan Teran <evan....@gmail.com> wrote:=20
>> > I would love to see <type_traits> have a template which looks like=20
>> this:=20
>> > template <size_t N>=20
>> > struct std::integer_of_size<N> {=20
>> >  typedef /* implementation defined */ type; // in case the=20
>> implementation=20
>> > doesn't want to care about signed-ness like for: char, signed char,=20
>> unsigned=20
>> > char=20
>> >  typedef /* implementation defined */ signed_type;=20
>> >  typedef /* implementation defined */ unsigned_type;=20
>> > };=20
>> > which for a given size N will give an easy method for getting a type o=
f=20
>> that=20
>> > size. I've written this before and it has proven useful time and time=
=20
>> again.=20
>> > It would be great if it were part of the standard.=20
>> > Example usage would of course look like this:=20
>> > typedef typename std::integer_of_size<64>::unsigned_type u64;=20
>> > u64 x =3D 1234;=20
>> > static_assert(sizeof(u64) =3D=3D sizeof(uint64_t), "Broken=20
>> integer_of_size"); //=20
>> > this should always be true=20
>> > I forget if that "typename" would be necessary in this particular=20
>> example.=20
>> > Strikes me as an easy and simple addition.=20
>>
>>
>> I doubt it's so simple. Types like uint8_t are optional because some=20
>> implementations=20
>> can't support them (they have eg. 24-bit chars). So what should such=20
>> platforms=20
>> do when encountering integer_of_size<8>?=20
>>
>
> What does int8_t do on that platform? It simply does not compile (I'd=20
> guess, with an "undefined type" error). I'd expect integer_of_size<8> do =
do=20
> the same (and in the meanwhile can provide a better error message as=20
> "Sorry, this platform does not support "+to_string(N)+"-bit integers" wit=
h=20
> a static_assert.)
>
> Also, the "proposal" can be extended with fast_integer<N>,=20
> integer_least<N>, meaning (u)int_fastN_t and (u)int_leastN_t
>
> Regards,
> Robert
>

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

<div dir=3D"ltr"><font face=3D"arial, sans-serif" size=3D"2">@R=C3=B3bert, =
That's precsely what I had in mind. Also I do like your idea of extending t=
his to cover the fast/least variants as well. Though I think we'd want to h=
ave a more consistent naming convention. Perhaps:</font><div><font face=3D"=
arial, sans-serif" size=3D"2"><br></font></div><div><font face=3D"arial, sa=
ns-serif" size=3D"2">std::integer&lt;N&gt;</font></div><div><span style=3D"=
font-family: arial, sans-serif; font-size: small;">std::</span><font face=
=3D"arial, sans-serif" size=3D"2">fast_integer&lt;N&gt;</font></div><div><s=
pan style=3D"font-family: arial, sans-serif; font-size: small;">std::</span=
><font face=3D"arial, sans-serif" size=3D"2">least_integer&lt;N&gt;</font><=
/div><div><br></div><div><font face=3D"arial, sans-serif" size=3D"2"><br></=
font><br>On Thursday, April 24, 2014 8:40:16 PM UTC-4, R=C3=B3bert D=C3=A1v=
id 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"><br>=
<br>2014. =C3=A1prilis 23., szerda 22:24:15 UTC+2 id=C5=91pontban Ville Vou=
tilainen a k=C3=B6vetkez=C5=91t =C3=ADrta:<blockquote class=3D"gmail_quote"=
 style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-lef=
t:1ex">On 23 April 2014 23:19, Evan Teran &lt;<a>evan....@gmail.com</a>&gt;=
 wrote:
<br>&gt; I would love to see &lt;type_traits&gt; have a template which look=
s like this:
<br>&gt; template &lt;size_t N&gt;
<br>&gt; struct std::integer_of_size&lt;N&gt; {
<br>&gt; &nbsp;typedef /* implementation defined */ type; // in case the im=
plementation
<br>&gt; doesn't want to care about signed-ness like for: char, signed char=
, unsigned
<br>&gt; char
<br>&gt; &nbsp;typedef /* implementation defined */ signed_type;
<br>&gt; &nbsp;typedef /* implementation defined */ unsigned_type;
<br>&gt; };
<br>&gt; which for a given size N will give an easy method for getting a ty=
pe of that
<br>&gt; size. I've written this before and it has proven useful time and t=
ime again.
<br>&gt; It would be great if it were part of the standard.
<br>&gt; Example usage would of course look like this:
<br>&gt; typedef typename std::integer_of_size&lt;64&gt;::<wbr>unsigned_typ=
e u64;
<br>&gt; u64 x =3D 1234;
<br>&gt; static_assert(sizeof(u64) =3D=3D sizeof(uint64_t), "Broken integer=
_of_size"); //
<br>&gt; this should always be true
<br>&gt; I forget if that "typename" would be necessary in this particular =
example.
<br>&gt; Strikes me as an easy and simple addition.
<br>
<br>
<br>I doubt it's so simple. Types like uint8_t are optional because some
<br>implementations
<br>can't support them (they have eg. 24-bit chars). So what should such pl=
atforms
<br>do when encountering integer_of_size&lt;8&gt;?
<br></blockquote><div><br>What does int8_t do on that platform? It simply d=
oes not compile (I'd guess, with an "undefined type" error). I'd expect int=
eger_of_size&lt;8&gt; do do the same (and in the meanwhile can provide a be=
tter error message as "Sorry, this platform does not support "+to_string(N)=
+"-bit integers" with a static_assert.)<br><br>Also, the "proposal" can be =
extended with fast_integer&lt;N&gt;, integer_least&lt;N&gt;, meaning (u)int=
_fastN_t and (u)int_leastN_t<br><br>Regards,<br>Robert<br></div></div></blo=
ckquote></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_72_6399838.1398433530565--

.


Author: Olaf van der Spek <olafvdspek@gmail.com>
Date: Sat, 26 Apr 2014 07:09:58 -0700 (PDT)
Raw View
------=_Part_13_14992719.1398521398296
Content-Type: text/plain; charset=UTF-8

Doesn't Boost provide this already?

--

---
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_13_14992719.1398521398296
Content-Type: text/html; charset=UTF-8

<div dir="ltr">Doesn't Boost provide this already?</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 email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

------=_Part_13_14992719.1398521398296--

.


Author: Felipe Magno de Almeida <felipe.m.almeida@gmail.com>
Date: Sat, 26 Apr 2014 15:27:55 -0300
Raw View
On Sat, Apr 26, 2014 at 11:09 AM, Olaf van der Spek
<olafvdspek@gmail.com> wrote:
> Doesn't Boost provide this already?

Yes. boost::uint_t<N>::least and ::exact in <boost/integer.hpp>.

Though it is probably quite hard to maintain it complete for every
compiler and compiler version with different integral primitive
extensions.

> --
>
> ---

Regards,
--
Felipe Magno de Almeida

--

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

.