Topic: fits_in


Author: Myriachan <myriachan@gmail.com>
Date: Fri, 1 Dec 2017 18:08:14 -0800 (PST)
Raw View
------=_Part_2145_151229359.1512180494407
Content-Type: multipart/alternative;
 boundary="----=_Part_2146_2036906020.1512180494407"

------=_Part_2146_2036906020.1512180494407
Content-Type: text/plain; charset="UTF-8"

I would like a function that determines whether a value of type A fits in a
value of type B.  For example, on a system with 32-bit two's-complement int
and 32-bit IEEE-754 float:


template <typename F, typename T>
constexpr bool fits_in(const T &value);

std::fits_in<int>(0x80000000u)  // false
std::fits_in<int, int>(0x80000000u)  // true
std::fits_in<int>(-0x7FFFFFFF - 1)  // true
std::fits_in<long long>(0x80000000u)  // true
std::fits_in<int>(std::bit_cast<float>(0x7F800000u))  // false, because
infinity
std::fits_in<int>(std::bit_cast<float>(0x7FC00000u))  // false, because NaN
std::fits_in<int>(1.23f);  // true, because we're asking whether the
*converted* value fits...?


Does this seem reasonable and useful?  It's similar to that
std::is_non_narrowing_conversion, but with values rather than just types.

I would use this when I need to convert to a smaller type, but want to
handle errors.

Melissa

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a5db1ea9-0047-4c1e-8e20-3d2866c37f48%40isocpp.org.

------=_Part_2146_2036906020.1512180494407
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I would like a function that determines whether a value of=
 type A fits in a value of type B.=C2=A0 For example, on a system with 32-b=
it two&#39;s-complement int and 32-bit IEEE-754 float:<br><br><br>template =
&lt;typename F, typename T&gt;<br>constexpr bool fits_in(const T &amp;value=
);<br><br>std::fits_in&lt;int&gt;(0x80000000u)=C2=A0 // false<br>std::fits_=
in&lt;int, int&gt;(0x80000000u)=C2=A0 // true<br>std::fits_in&lt;int&gt;(-0=
x7FFFFFFF - 1)=C2=A0 // true<br>std::fits_in&lt;long long&gt;(0x80000000u)=
=C2=A0 // true<br>std::fits_in&lt;int&gt;(std::bit_cast&lt;float&gt;(0x7F80=
0000u))=C2=A0 // false, because infinity<br>std::fits_in&lt;int&gt;(std::bi=
t_cast&lt;float&gt;(0x7FC00000u))=C2=A0 // false, because NaN<br>std::fits_=
in&lt;int&gt;(1.23f);=C2=A0 // true, because we&#39;re asking whether the *=
converted* value fits...?<br><br><br>Does this seem reasonable and useful?=
=C2=A0 It&#39;s similar to that std::is_non_narrowing_conversion, but with =
values rather than just types.<br><br>I would use this when I need to conve=
rt to a smaller type, but want to handle errors.<br><br>Melissa<br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a5db1ea9-0047-4c1e-8e20-3d2866c37f48%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a5db1ea9-0047-4c1e-8e20-3d2866c37f48=
%40isocpp.org</a>.<br />

------=_Part_2146_2036906020.1512180494407--

------=_Part_2145_151229359.1512180494407--

.


Author: "Tam S. B." <cpplearner@outlook.com>
Date: Sat, 2 Dec 2017 14:39:20 +0000
Raw View
This sounds like `in_range` in [P0586R0](http://www.open-std.org/jtc1/sc22/=
wg21/docs/papers/2017/p0586r0.html), though P0586R0 does not handle floatin=
g-point types.

________________________________________
From: Myriachan <myriachan@gmail.com>
Sent: Saturday, December 2, 2017 2:08:14 AM
To: ISO C++ Standard - Future Proposals
Subject: [std-proposals] fits_in

I would like a function that determines whether a value of type A fits in a=
 value of type B.  For example, on a system with 32-bit two's-complement in=
t and 32-bit IEEE-754 float:


template <typename F, typename T>
constexpr bool fits_in(const T &value);

std::fits_in<int>(0x80000000u)  // false
std::fits_in<int, int>(0x80000000u)  // true
std::fits_in<int>(-0x7FFFFFFF - 1)  // true
std::fits_in<long long>(0x80000000u)  // true
std::fits_in<int>(std::bit_cast<float>(0x7F800000u))  // false, because inf=
inity
std::fits_in<int>(std::bit_cast<float>(0x7FC00000u))  // false, because NaN
std::fits_in<int>(1.23f);  // true, because we're asking whether the *conve=
rted* value fits...?


Does this seem reasonable and useful?  It's similar to that std::is_non_nar=
rowing_conversion, but with values rather than just types.

I would use this when I need to convert to a smaller type, but want to hand=
le errors.

Melissa

--
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<mailto:std-proposals+unsubscri=
be@isocpp.org>.
To post to this group, send email to std-proposals@isocpp.org<mailto:std-pr=
oposals@isocpp.org>.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/a5db1ea9-0047-4c1e-8e20-3d2866c37f48%40isocpp.or=
g<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a5db1ea9-004=
7-4c1e-8e20-3d2866c37f48%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoote=
r>.

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/SG2PR0301MB13048C5FE67D4745A96AD4B7E53E0%40SG2PR=
0301MB1304.apcprd03.prod.outlook.com.

.


Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Sat, 2 Dec 2017 16:11:11 +0000
Raw View
--001a11492a42e38c34055f5dbbf7
Content-Type: text/plain; charset="UTF-8"

On 2 Dec 2017 02:08, "Myriachan" <myriachan@gmail.com> wrote:

Does this seem reasonable and useful?  It's similar to that
std::is_non_narrowing_conversion, but with values rather than just types.

I would use this when I need to convert to a smaller type, but want to
handle errors.


One-liners aside, how would this fit into (pun intended) a program? Can you
provide a use case? This isnt a criticism, I would just like to gauge how
useful it would be, and I can't immediately see that yet.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCNLEm8_eCxXm58agjB8H0A21pA91n-%3DEyfgwadNfMnAcA%40mail.gmail.com.

--001a11492a42e38c34055f5dbbf7
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div><div class=3D"gmail_extra"><div class=3D"gmail_quote=
">On 2 Dec 2017 02:08, &quot;Myriachan&quot; &lt;<a href=3D"mailto:myriacha=
n@gmail.com" target=3D"_blank">myriachan@gmail.com</a>&gt; wrote:<br type=
=3D"attribution"><blockquote class=3D"m_-7079826279042973454m_-910850980574=
6808309m_-4823082503946673875m_-9060281434851131110quote" style=3D"margin:0=
 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Doe=
s this seem reasonable and useful?=C2=A0 It&#39;s similar to that std::is_n=
on_narrowing_conversi<wbr>on, but with values rather than just types.<br><b=
r>I would use this when I need to convert to a smaller type, but want to ha=
ndle errors.<br></div></blockquote></div></div></div><div dir=3D"auto"><br>=
</div><div dir=3D"auto">One-liners aside, how would this fit into (pun inte=
nded) a program? Can you provide a use case? This isnt a criticism, I would=
 just like to gauge how useful it would be, and I can&#39;t immediately see=
 that yet.</div><div dir=3D"auto"><div class=3D"gmail_extra"><div class=3D"=
gmail_quote"><blockquote class=3D"m_-7079826279042973454m_-9108509805746808=
309m_-4823082503946673875m_-9060281434851131110quote" style=3D"margin:0 0 0=
 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"></div><=
/blockquote></div><br></div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCNLEm8_eCxXm58agjB8H0A21pA91n=
-%3DEyfgwadNfMnAcA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCNLEm=
8_eCxXm58agjB8H0A21pA91n-%3DEyfgwadNfMnAcA%40mail.gmail.com</a>.<br />

--001a11492a42e38c34055f5dbbf7--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Sat, 02 Dec 2017 11:06:04 -0800
Raw View
On Friday, 1 December 2017 18:08:14 PST Myriachan wrote:
> I would like a function that determines whether a value of type A fits in a
> value of type B.  For example, on a system with 32-bit two's-complement int
> and 32-bit IEEE-754 float:

Sounds like
https://groups.google.com/a/isocpp.org/d/msg/std-proposals/FwasK14dTNI/
aB1SsOVbBwAJ
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2243687.6dNIIbcheD%40tjmaciei-mobl1.

.


Author: John McFarlane <john@mcfarlane.name>
Date: Sun, 03 Dec 2017 23:29:53 +0000
Raw View
--94eb2c0949d038d8e4055f77fb4f
Content-Type: text/plain; charset="UTF-8"

On Sat, Dec 2, 2017 at 8:11 AM Jake Arkinstall <jake.arkinstall@gmail.com>
wrote:

> On 2 Dec 2017 02:08, "Myriachan" <myriachan@gmail.com> wrote:
>
> Does this seem reasonable and useful?  It's similar to that
> std::is_non_narrowing_conversion, but with values rather than just types.
>
> I would use this when I need to convert to a smaller type, but want to
> handle errors.
>
>
> One-liners aside, how would this fit into (pun intended) a program? Can
> you provide a use case? This isnt a criticism, I would just like to gauge
> how useful it would be, and I can't immediately see that yet.
>

I have implemented this in a safe_integer-like type and would use it if it
were in the standard. It also overlaps with functionality proposed in P0105
[1] and as such would be of value in implementing types such as those in
P0106 [2] and P0554 [3].

John

1.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0105r1.html#OverFunctions
2.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0106r0.html#basic_types
3. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0554r0.html

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CABPJVnRu%2B664nTuYVtYDqi2MnXCChn83vghQhqy5BBvqVZ_zaA%40mail.gmail.com.

--94eb2c0949d038d8e4055f77fb4f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sat, Dec 2, 2017 at 8:11 AM Jake Arkinstall &lt;<a href=
=3D"mailto:jake.arkinstall@gmail.com">jake.arkinstall@gmail.com</a>&gt; wro=
te:<br><div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div =
dir=3D"auto"><div><div class=3D"gmail_extra"><div class=3D"gmail_quote">On =
2 Dec 2017 02:08, &quot;Myriachan&quot; &lt;<a href=3D"mailto:myriachan@gma=
il.com" target=3D"_blank">myriachan@gmail.com</a>&gt; wrote:<br type=3D"att=
ribution"><blockquote class=3D"m_277327063111727549m_-7079826279042973454m_=
-9108509805746808309m_-4823082503946673875m_-9060281434851131110quote" styl=
e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div di=
r=3D"ltr">Does this seem reasonable and useful?=C2=A0 It&#39;s similar to t=
hat std::is_non_narrowing_conversion, but with values rather than just type=
s.<br><br>I would use this when I need to convert to a smaller type, but wa=
nt to handle errors.<br></div></blockquote></div></div></div><div dir=3D"au=
to"><br></div></div><div dir=3D"auto"><div dir=3D"auto">One-liners aside, h=
ow would this fit into (pun intended) a program? Can you provide a use case=
? This isnt a criticism, I would just like to gauge how useful it would be,=
 and I can&#39;t immediately see that yet.</div></div></blockquote><div><br=
></div><div>I have implemented this in a safe_integer-like type and would u=
se it if it were in the standard. It also overlaps with functionality propo=
sed in P0105 [1] and as such would be of value in implementing types such a=
s those in P0106 [2] and P0554 [3].</div><div><br></div><div>John<br></div>=
<div><br></div><div>1. <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/do=
cs/papers/2017/p0105r1.html#OverFunctions">http://www.open-std.org/jtc1/sc2=
2/wg21/docs/papers/2017/p0105r1.html#OverFunctions</a></div><div>2. <a href=
=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0106r0.html#ba=
sic_types">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0106r0.=
html#basic_types</a></div><div>3. <a href=3D"http://www.open-std.org/jtc1/s=
c22/wg21/docs/papers/2017/p0554r0.html">http://www.open-std.org/jtc1/sc22/w=
g21/docs/papers/2017/p0554r0.html</a></div></div><div class=3D"gmail_quote"=
><br></div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CABPJVnRu%2B664nTuYVtYDqi2MnXCChn83vg=
hQhqy5BBvqVZ_zaA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CABPJVnRu%2B664=
nTuYVtYDqi2MnXCChn83vghQhqy5BBvqVZ_zaA%40mail.gmail.com</a>.<br />

--94eb2c0949d038d8e4055f77fb4f--

.


Author: Myriachan <myriachan@gmail.com>
Date: Sun, 3 Dec 2017 18:04:06 -0800 (PST)
Raw View
------=_Part_7229_326930978.1512353046504
Content-Type: multipart/alternative;
 boundary="----=_Part_7230_882947394.1512353046504"

------=_Part_7230_882947394.1512353046504
Content-Type: text/plain; charset="UTF-8"

On Saturday, December 2, 2017 at 8:11:14 AM UTC-8, Jake Arkinstall wrote:
>
> On 2 Dec 2017 02:08, "Myriachan" <myri...@gmail.com <javascript:>> wrote:
>
> Does this seem reasonable and useful?  It's similar to that
> std::is_non_narrowing_conversion, but with values rather than just types.
>
> I would use this when I need to convert to a smaller type, but want to
> handle errors.
>
>
> One-liners aside, how would this fit into (pun intended) a program? Can
> you provide a use case? This isnt a criticism, I would just like to gauge
> how useful it would be, and I can't immediately see that yet.
>
>
>
Hmm, something like this I suppose.

void RawWrite(Handle *handle, const void *data, size_t size)
{
#ifdef _WIN32
    DWORD written;
    if (!std::fits_in<DWORD>(size))
        throw "size too large for DWORD";
    if (!WriteFile(handle->m_handle, data, static_cast<DWORD>(size),
&written, nullptr))
        throw "IO error";
    if (written != size)
        throw "partial write";
#else
    if (!std::fits_in<ssize_t>(size))
        throw "size too large for ssize_t";
    ssize_t written = write(handle->m_fd, data, size);
    if (written < 0)
        throw "IO error";
    if (static_cast<size_t>(written) != size)
        throw "partial write";
#endif
}



On Saturday, December 2, 2017 at 11:06:07 AM UTC-8, Thiago Macieira wrote:
>
> Sounds like
> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/FwasK14dTNI/
> aB1SsOVbBwAJ
> <https://groups.google.com/a/isocpp.org/d/msg/std-proposals/FwasK14dTNI/aB1SsOVbBwAJ>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>    Software Architect - Intel Open Source Technology Center
>
>
Yes, like that, but runtime instead of compile time.  That compile-time
version returns whether any value of the "from" type will always fit in the
"to" type.  The runtime version would return whether that specific value
does.  For example, std::is_narrowing_conversion<int, char> is (probably)
true, whereas std::fits_in<char>(123) would be true, even though ints in
general might not fit.


It does seem like there are a few proposals along similar lines, but cover
more ground than my simple idea.

Melissa

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/bd670230-2715-4eb3-ad51-41381eb91b5e%40isocpp.org.

------=_Part_7230_882947394.1512353046504
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Saturday, December 2, 2017 at 8:11:14 AM UTC-8, Jake Ar=
kinstall 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"aut=
o"><div><div><div class=3D"gmail_quote">On 2 Dec 2017 02:08, &quot;Myriacha=
n&quot; &lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=
=3D"Rjxga9QuBgAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascri=
pt:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return =
true;">myri...@gmail.com</a>&gt; wrote:<br type=3D"attribution"><blockquote=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><d=
iv dir=3D"ltr">Does this seem reasonable and useful?=C2=A0 It&#39;s similar=
 to that std::is_non_narrowing_<wbr>conversion, but with values rather than=
 just types.<br><br>I would use this when I need to convert to a smaller ty=
pe, but want to handle errors.<br></div></blockquote></div></div></div><div=
 dir=3D"auto"><br></div><div dir=3D"auto">One-liners aside, how would this =
fit into (pun intended) a program? Can you provide a use case? This isnt a =
criticism, I would just like to gauge how useful it would be, and I can&#39=
;t immediately see that yet.</div><div dir=3D"auto"><div><div class=3D"gmai=
l_quote"><blockquote style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;=
padding-left:1ex"><div dir=3D"ltr"></div></blockquote></div><br></div></div=
></div></blockquote><div><br></div><div>Hmm, something like this I suppose.=
<br></div><div><br></div><div>void RawWrite(Handle *handle, const void *dat=
a, size_t size)</div><div>{</div><div>#ifdef _WIN32</div><div>=C2=A0=C2=A0=
=C2=A0 DWORD written;</div><div>=C2=A0=C2=A0=C2=A0 if (!std::fits_in&lt;DWO=
RD&gt;(size))</div><div>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 throw &q=
uot;size too large for DWORD&quot;;</div><div>=C2=A0=C2=A0=C2=A0 if (!Write=
File(handle-&gt;m_handle, data, static_cast&lt;DWORD&gt;(size), &amp;writte=
n, nullptr))</div><div>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 throw &qu=
ot;IO error&quot;;</div><div>=C2=A0=C2=A0=C2=A0 if (written !=3D size)</div=
><div>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 throw &quot;partial write&=
quot;;</div><div>#else</div><div>=C2=A0=C2=A0=C2=A0 if (!std::fits_in&lt;ss=
ize_t&gt;(size))</div><div>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 throw=
 &quot;size too large for ssize_t&quot;;</div><div>=C2=A0=C2=A0=C2=A0 ssize=
_t written =3D write(handle-&gt;m_fd, data, size);</div><div>=C2=A0=C2=A0=
=C2=A0 if (written &lt; 0)</div><div>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 throw &quot;IO error&quot;;</div><div>=C2=A0=C2=A0=C2=A0 if (static_=
cast&lt;size_t&gt;(written) !=3D size)</div><div>=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 throw &quot;partial write&quot;;<br></div><div>#endif<br=
></div><div>}</div><div><br></div><div><br><br>On Saturday, December 2, 201=
7 at 11:06:07 AM UTC-8, Thiago Macieira wrote:<blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padd=
ing-left: 1ex;">Sounds like=20
<br><a href=3D"https://groups.google.com/a/isocpp.org/d/msg/std-proposals/F=
wasK14dTNI/aB1SsOVbBwAJ" target=3D"_blank" rel=3D"nofollow">https://groups.=
google.com/a/<wbr>isocpp.org/d/msg/std-<wbr>proposals/FwasK14dTNI/
<br>aB1SsOVbBwAJ</a>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow">macieira.info</a> - thiago (AT) <a href=3D"htt=
p://kde.org" target=3D"_blank" rel=3D"nofollow">kde.org</a>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote><div>=C2=A0</div><div>Yes, like that, but runtime instead =
of compile time.=C2=A0 That compile-time version returns whether any value =
of the &quot;from&quot; type will always fit in the &quot;to&quot; type.=C2=
=A0 The runtime version would return whether that specific value does.=C2=
=A0 For example, std::is_narrowing_conversion&lt;int, char&gt; is (probably=
) true, whereas std::fits_in&lt;char&gt;(123) would be true, even though in=
ts in general might not fit.</div><div><br></div><div><br></div><div>It doe=
s seem like there are a few proposals along similar lines, but cover more g=
round than my simple idea.<br></div><div><br></div><div>Melissa<br></div></=
div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/bd670230-2715-4eb3-ad51-41381eb91b5e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/bd670230-2715-4eb3-ad51-41381eb91b5e=
%40isocpp.org</a>.<br />

------=_Part_7230_882947394.1512353046504--

------=_Part_7229_326930978.1512353046504--

.