Topic: Proposal for <numeric>: rounded-up integral


Author: Dawid Pilarski <dawidpicpp@gmail.com>
Date: Fri, 9 Dec 2016 10:21:25 +0100
Raw View
--089e013d18c03f41b90543364794
Content-Type: text/plain; charset=UTF-8

I do not quite like the idea of operator + and operator -. It's kind of
misleading, that operator + and - has so strange meaning. Why not doing
just simple function round_up_to_multiple, which would have cleaner
interface?


2016-12-08 19:39 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future
Proposals <std-proposals@isocpp.org>:

> #include <type_traits>
>
>
> template <typename I>
> struct mround_type
>   {
>     static_assert(
>       std::is_integral<I>::value, "mround_type requires integral type");
>
>
>     const I value;
>
>
>     constexpr explicit mround_type(I v) : value(v) { }
>   };
>
>
> template <typename I>
> constexpr auto mround(I i)
>   {
>     static_assert(
>       std::is_integral<I>::value,
>       "mround() parameter must be of integral type");
>
>
>     return(mround_type<I>(i));
>   }
>
>
> // Rounded-up integral division.
> template <typename I>
> constexpr I operator / (I i, mround_type<I> factor)
>   {
>     return((i + factor.value - 1) / factor.value);
>   }
>
>
> // Round up integer to multiple.
> template <typename I>
> constexpr I operator + (I i, mround_type<I> factor)
>   {
>     return((i / factor) * factor.value);
>   }
>
>
> // Round down integer to multiple.
> template <typename I>
> constexpr I operator - (I i, mround_type<I> factor)
>   {
>     return(i - (i % factor.value));
>   }
>
>
> static_assert(9 / mround(5) == 2, "");
> static_assert(10 / mround(5) == 2, "");
> static_assert(11 / mround(5) == 3, "");
>
>
> static_assert(9 + mround(5) == 10, "");
> static_assert(10 + mround(5) == 10, "");
> static_assert(11 + mround(5) == 15, "");
>
>
> static_assert(9 - mround(5) == 5, "");
> static_assert(10 - mround(5) == 10, "");
> static_assert(11 - mround(5) == 10, "");
>
>
>
> --
> 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/1af197bf-4e85-4e4b-
> 9486-dd7ca150c139%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
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/CAOkZZiHVe-3-jfGOcYgrwFVksPRwrRZK7__G%3Ds-01Def-qTZiQ%40mail.gmail.com.

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

<div dir=3D"ltr"><code>I do not quite like the idea of operator + and opera=
tor -. It&#39;s kind of misleading, that operator + and - has so strange me=
aning. Why not doing just simple function round_up_to_multiple, which would=
 have cleaner interface?</code><code class=3D"gmail-m_1718169008803030191pr=
ettyprint"><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_17181690088030=
30191styled-by-prettify"><br><br></span></code></div><div class=3D"gmail_ex=
tra"><br><div class=3D"gmail_quote">2016-12-08 19:39 GMT+01:00 &#39;Walt Ka=
ras&#39; via ISO C++ Standard - Future Proposals <span dir=3D"ltr">&lt;<a h=
ref=3D"mailto:std-proposals@isocpp.org" target=3D"_blank">std-proposals@iso=
cpp.org</a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">=
<div class=3D"m_1718169008803030191prettyprint" style=3D"background-color:r=
gb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-wid=
th:1px;word-wrap:break-word"><code class=3D"m_1718169008803030191prettyprin=
t"><div class=3D"m_1718169008803030191subprettyprint"><span style=3D"color:=
#800" class=3D"m_1718169008803030191styled-by-prettify">#include</span><spa=
n style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> <=
/span><span style=3D"color:#080" class=3D"m_1718169008803030191styled-by-pr=
ettify">&lt;type_traits&gt;</span><span style=3D"color:#000" class=3D"m_171=
8169008803030191styled-by-prettify"><br><br><br></span><span style=3D"color=
:#008" class=3D"m_1718169008803030191styled-by-prettify">template</span><sp=
an style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> =
</span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-p=
rettify">&lt;</span><span style=3D"color:#008" class=3D"m_17181690088030301=
91styled-by-prettify">typename</span><span style=3D"color:#000" class=3D"m_=
1718169008803030191styled-by-prettify"> I</span><span style=3D"color:#660" =
class=3D"m_1718169008803030191styled-by-prettify">&gt;</span><span style=3D=
"color:#000" class=3D"m_1718169008803030191styled-by-prettify"><br></span><=
span style=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify"=
>struct</span><span style=3D"color:#000" class=3D"m_1718169008803030191styl=
ed-by-prettify"> mround_type<br>=C2=A0 </span><span style=3D"color:#660" cl=
ass=3D"m_1718169008803030191styled-by-prettify">{</span><span style=3D"colo=
r:#000" class=3D"m_1718169008803030191styled-by-prettify"><br>=C2=A0 =C2=A0=
 </span><span style=3D"color:#008" class=3D"m_1718169008803030191styled-by-=
prettify">static_assert</span><span style=3D"color:#660" class=3D"m_1718169=
008803030191styled-by-prettify">(</span><span style=3D"color:#000" class=3D=
"m_1718169008803030191styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 std</spa=
n><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pretti=
fy">::</span><span style=3D"color:#000" class=3D"m_1718169008803030191style=
d-by-prettify">is_integral</span><span style=3D"color:#660" class=3D"m_1718=
169008803030191styled-by-prettify">&lt;</span><span style=3D"color:#000" cl=
ass=3D"m_1718169008803030191styled-by-prettify">I</span><span style=3D"colo=
r:#660" class=3D"m_1718169008803030191styled-by-prettify">&gt;::</span><spa=
n style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify">va=
lue</span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-b=
y-prettify">,</span><span style=3D"color:#000" class=3D"m_17181690088030301=
91styled-by-prettify"> </span><span style=3D"color:#080" class=3D"m_1718169=
008803030191styled-by-prettify">&quot;mround_type requires integral type&qu=
ot;</span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-b=
y-prettify">);</span><span style=3D"color:#000" class=3D"m_1718169008803030=
191styled-by-prettify"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"colo=
r:#008" class=3D"m_1718169008803030191styled-by-prettify">const</span><span=
 style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> I =
value</span><span style=3D"color:#660" class=3D"m_1718169008803030191styled=
-by-prettify">;</span><span style=3D"color:#000" class=3D"m_171816900880303=
0191styled-by-prettify"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"col=
or:#008" class=3D"m_1718169008803030191styled-by-prettify">constexpr</span>=
<span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify=
"> </span><span style=3D"color:#008" class=3D"m_1718169008803030191styled-b=
y-prettify">explicit</span><span style=3D"color:#000" class=3D"m_1718169008=
803030191styled-by-prettify"> mround_type</span><span style=3D"color:#660" =
class=3D"m_1718169008803030191styled-by-prettify">(</span><span style=3D"co=
lor:#000" class=3D"m_1718169008803030191styled-by-prettify">I v</span><span=
 style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">)</=
span><span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-pre=
ttify"> </span><span style=3D"color:#660" class=3D"m_1718169008803030191sty=
led-by-prettify">:</span><span style=3D"color:#000" class=3D"m_171816900880=
3030191styled-by-prettify"> value</span><span style=3D"color:#660" class=3D=
"m_1718169008803030191styled-by-prettify">(</span><span style=3D"color:#000=
" class=3D"m_1718169008803030191styled-by-prettify">v</span><span style=3D"=
color:#660" class=3D"m_1718169008803030191styled-by-prettify">)</span><span=
 style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> </=
span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pre=
ttify">{</span><span style=3D"color:#000" class=3D"m_1718169008803030191sty=
led-by-prettify"> </span><span style=3D"color:#660" class=3D"m_171816900880=
3030191styled-by-prettify">}</span><span style=3D"color:#000" class=3D"m_17=
18169008803030191styled-by-prettify"><br>=C2=A0 </span><span style=3D"color=
:#660" class=3D"m_1718169008803030191styled-by-prettify">};</span><span sty=
le=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"><br><br=
><br></span><span style=3D"color:#008" class=3D"m_1718169008803030191styled=
-by-prettify">template</span><span style=3D"color:#000" class=3D"m_17181690=
08803030191styled-by-prettify"> </span><span style=3D"color:#660" class=3D"=
m_1718169008803030191styled-by-prettify">&lt;</span><span style=3D"color:#0=
08" class=3D"m_1718169008803030191styled-by-prettify">typename</span><span =
style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> I</=
span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pre=
ttify">&gt;</span><span style=3D"color:#000" class=3D"m_1718169008803030191=
styled-by-prettify"><br></span><span style=3D"color:#008" class=3D"m_171816=
9008803030191styled-by-prettify">constexpr</span><span style=3D"color:#000"=
 class=3D"m_1718169008803030191styled-by-prettify"> </span><span style=3D"c=
olor:#008" class=3D"m_1718169008803030191styled-by-prettify">auto</span><sp=
an style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> =
mround</span><span style=3D"color:#660" class=3D"m_1718169008803030191style=
d-by-prettify">(</span><span style=3D"color:#000" class=3D"m_17181690088030=
30191styled-by-prettify">I i</span><span style=3D"color:#660" class=3D"m_17=
18169008803030191styled-by-prettify">)</span><span style=3D"color:#000" cla=
ss=3D"m_1718169008803030191styled-by-prettify"><br>=C2=A0 </span><span styl=
e=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">{</span>=
<span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify=
"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_1718169008=
803030191styled-by-prettify">static_assert</span><span style=3D"color:#660"=
 class=3D"m_1718169008803030191styled-by-prettify">(</span><span style=3D"c=
olor:#000" class=3D"m_1718169008803030191styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 std</span><span style=3D"color:#660" class=3D"m_1718169008803030=
191styled-by-prettify">::</span><span style=3D"color:#000" class=3D"m_17181=
69008803030191styled-by-prettify">is_integral</span><span style=3D"color:#6=
60" class=3D"m_1718169008803030191styled-by-prettify">&lt;</span><span styl=
e=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify">I</span>=
<span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify=
">&gt;::</span><span style=3D"color:#000" class=3D"m_1718169008803030191sty=
led-by-prettify">value</span><span style=3D"color:#660" class=3D"m_17181690=
08803030191styled-by-prettify">,</span><span style=3D"color:#000" class=3D"=
m_1718169008803030191styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 </span><s=
pan style=3D"color:#080" class=3D"m_1718169008803030191styled-by-prettify">=
&quot;mround() parameter must be of integral type&quot;</span><span style=
=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">);</span>=
<span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify=
"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_17=
18169008803030191styled-by-prettify">return</span><span style=3D"color:#660=
" class=3D"m_1718169008803030191styled-by-prettify">(</span><span style=3D"=
color:#000" class=3D"m_1718169008803030191styled-by-prettify">mround_type</=
span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pre=
ttify">&lt;</span><span style=3D"color:#000" class=3D"m_1718169008803030191=
styled-by-prettify">I</span><span style=3D"color:#660" class=3D"m_171816900=
8803030191styled-by-prettify">&gt;(</span><span style=3D"color:#000" class=
=3D"m_1718169008803030191styled-by-prettify">i</span><span style=3D"color:#=
660" class=3D"m_1718169008803030191styled-by-prettify">));</span><span styl=
e=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"><br>=C2=
=A0 </span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-=
by-prettify">}</span><span style=3D"color:#000" class=3D"m_1718169008803030=
191styled-by-prettify"><br><br><br></span><span style=3D"color:#800" class=
=3D"m_1718169008803030191styled-by-prettify">// Rounded-up integral divisio=
n.</span><span style=3D"color:#000" class=3D"m_1718169008803030191styled-by=
-prettify"><br></span><span style=3D"color:#008" class=3D"m_171816900880303=
0191styled-by-prettify">template</span><span style=3D"color:#000" class=3D"=
m_1718169008803030191styled-by-prettify"> </span><span style=3D"color:#660"=
 class=3D"m_1718169008803030191styled-by-prettify">&lt;</span><span style=
=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify">typename<=
/span><span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-pr=
ettify"> I</span><span style=3D"color:#660" class=3D"m_1718169008803030191s=
tyled-by-prettify">&gt;</span><span style=3D"color:#000" class=3D"m_1718169=
008803030191styled-by-prettify"><br></span><span style=3D"color:#008" class=
=3D"m_1718169008803030191styled-by-prettify">constexpr</span><span style=3D=
"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> I </span><s=
pan style=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify">=
operator</span><span style=3D"color:#000" class=3D"m_1718169008803030191sty=
led-by-prettify"> </span><span style=3D"color:#660" class=3D"m_171816900880=
3030191styled-by-prettify">/</span><span style=3D"color:#000" class=3D"m_17=
18169008803030191styled-by-prettify"> </span><span style=3D"color:#660" cla=
ss=3D"m_1718169008803030191styled-by-prettify">(</span><span style=3D"color=
:#000" class=3D"m_1718169008803030191styled-by-prettify">I i</span><span st=
yle=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">,</spa=
n><span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-pretti=
fy"> mround_type</span><span style=3D"color:#660" class=3D"m_17181690088030=
30191styled-by-prettify">&lt;</span><span style=3D"color:#000" class=3D"m_1=
718169008803030191styled-by-prettify">I</span><span style=3D"color:#660" cl=
ass=3D"m_1718169008803030191styled-by-prettify">&gt;</span><span style=3D"c=
olor:#000" class=3D"m_1718169008803030191styled-by-prettify"> factor</span>=
<span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify=
">)</span><span style=3D"color:#000" class=3D"m_1718169008803030191styled-b=
y-prettify"><br>=C2=A0 </span><span style=3D"color:#660" class=3D"m_1718169=
008803030191styled-by-prettify">{</span><span style=3D"color:#000" class=3D=
"m_1718169008803030191styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify">return=
</span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-p=
rettify">((</span><span style=3D"color:#000" class=3D"m_1718169008803030191=
styled-by-prettify">i </span><span style=3D"color:#660" class=3D"m_17181690=
08803030191styled-by-prettify">+</span><span style=3D"color:#000" class=3D"=
m_1718169008803030191styled-by-prettify"> factor</span><span style=3D"color=
:#660" class=3D"m_1718169008803030191styled-by-prettify">.</span><span styl=
e=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify">value </=
span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pre=
ttify">-</span><span style=3D"color:#000" class=3D"m_1718169008803030191sty=
led-by-prettify"> </span><span style=3D"color:#066" class=3D"m_171816900880=
3030191styled-by-prettify">1</span><span style=3D"color:#660" class=3D"m_17=
18169008803030191styled-by-prettify">)</span><span style=3D"color:#000" cla=
ss=3D"m_1718169008803030191styled-by-prettify"> </span><span style=3D"color=
:#660" class=3D"m_1718169008803030191styled-by-prettify">/</span><span styl=
e=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> factor<=
/span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pr=
ettify">.</span><span style=3D"color:#000" class=3D"m_1718169008803030191st=
yled-by-prettify">value</span><span style=3D"color:#660" class=3D"m_1718169=
008803030191styled-by-prettify">);</span><span style=3D"color:#000" class=
=3D"m_1718169008803030191styled-by-prettify"><br>=C2=A0 </span><span style=
=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">}</span><=
span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"=
><br><br><br></span><span style=3D"color:#800" class=3D"m_17181690088030301=
91styled-by-prettify">// Round up integer to multiple.</span><span style=3D=
"color:#000" class=3D"m_1718169008803030191styled-by-prettify"><br></span><=
span style=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify"=
>template</span><span style=3D"color:#000" class=3D"m_1718169008803030191st=
yled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_17181690088=
03030191styled-by-prettify">&lt;</span><span style=3D"color:#008" class=3D"=
m_1718169008803030191styled-by-prettify">typename</span><span style=3D"colo=
r:#000" class=3D"m_1718169008803030191styled-by-prettify"> I</span><span st=
yle=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">&gt;</=
span><span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-pre=
ttify"><br></span><span style=3D"color:#008" class=3D"m_1718169008803030191=
styled-by-prettify">constexpr</span><span style=3D"color:#000" class=3D"m_1=
718169008803030191styled-by-prettify"> I </span><span style=3D"color:#008" =
class=3D"m_1718169008803030191styled-by-prettify">operator</span><span styl=
e=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> </span>=
<span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify=
">+</span><span style=3D"color:#000" class=3D"m_1718169008803030191styled-b=
y-prettify"> </span><span style=3D"color:#660" class=3D"m_17181690088030301=
91styled-by-prettify">(</span><span style=3D"color:#000" class=3D"m_1718169=
008803030191styled-by-prettify">I i</span><span style=3D"color:#660" class=
=3D"m_1718169008803030191styled-by-prettify">,</span><span style=3D"color:#=
000" class=3D"m_1718169008803030191styled-by-prettify"> mround_type</span><=
span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify"=
>&lt;</span><span style=3D"color:#000" class=3D"m_1718169008803030191styled=
-by-prettify">I</span><span style=3D"color:#660" class=3D"m_171816900880303=
0191styled-by-prettify">&gt;</span><span style=3D"color:#000" class=3D"m_17=
18169008803030191styled-by-prettify"> factor</span><span style=3D"color:#66=
0" class=3D"m_1718169008803030191styled-by-prettify">)</span><span style=3D=
"color:#000" class=3D"m_1718169008803030191styled-by-prettify"><br>=C2=A0 <=
/span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pr=
ettify">{</span><span style=3D"color:#000" class=3D"m_1718169008803030191st=
yled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=
=3D"m_1718169008803030191styled-by-prettify">return</span><span style=3D"co=
lor:#660" class=3D"m_1718169008803030191styled-by-prettify">((</span><span =
style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify">i </=
span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pre=
ttify">/</span><span style=3D"color:#000" class=3D"m_1718169008803030191sty=
led-by-prettify"> factor</span><span style=3D"color:#660" class=3D"m_171816=
9008803030191styled-by-prettify">)</span><span style=3D"color:#000" class=
=3D"m_1718169008803030191styled-by-prettify"> </span><span style=3D"color:#=
660" class=3D"m_1718169008803030191styled-by-prettify">*</span><span style=
=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> factor</=
span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pre=
ttify">.</span><span style=3D"color:#000" class=3D"m_1718169008803030191sty=
led-by-prettify">value</span><span style=3D"color:#660" class=3D"m_17181690=
08803030191styled-by-prettify">);</span><span style=3D"color:#000" class=3D=
"m_1718169008803030191styled-by-prettify"><br>=C2=A0 </span><span style=3D"=
color:#660" class=3D"m_1718169008803030191styled-by-prettify">}</span><span=
 style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"><br=
><br><br></span><span style=3D"color:#800" class=3D"m_1718169008803030191st=
yled-by-prettify">// Round down integer to multiple.</span><span style=3D"c=
olor:#000" class=3D"m_1718169008803030191styled-by-prettify"><br></span><sp=
an style=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify">t=
emplate</span><span style=3D"color:#000" class=3D"m_1718169008803030191styl=
ed-by-prettify"> </span><span style=3D"color:#660" class=3D"m_1718169008803=
030191styled-by-prettify">&lt;</span><span style=3D"color:#008" class=3D"m_=
1718169008803030191styled-by-prettify">typename</span><span style=3D"color:=
#000" class=3D"m_1718169008803030191styled-by-prettify"> I</span><span styl=
e=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">&gt;</sp=
an><span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prett=
ify"><br></span><span style=3D"color:#008" class=3D"m_1718169008803030191st=
yled-by-prettify">constexpr</span><span style=3D"color:#000" class=3D"m_171=
8169008803030191styled-by-prettify"> I </span><span style=3D"color:#008" cl=
ass=3D"m_1718169008803030191styled-by-prettify">operator</span><span style=
=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> </span><=
span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify"=
>-</span><span style=3D"color:#000" class=3D"m_1718169008803030191styled-by=
-prettify"> </span><span style=3D"color:#660" class=3D"m_171816900880303019=
1styled-by-prettify">(</span><span style=3D"color:#000" class=3D"m_17181690=
08803030191styled-by-prettify">I i</span><span style=3D"color:#660" class=
=3D"m_1718169008803030191styled-by-prettify">,</span><span style=3D"color:#=
000" class=3D"m_1718169008803030191styled-by-prettify"> mround_type</span><=
span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify"=
>&lt;</span><span style=3D"color:#000" class=3D"m_1718169008803030191styled=
-by-prettify">I</span><span style=3D"color:#660" class=3D"m_171816900880303=
0191styled-by-prettify">&gt;</span><span style=3D"color:#000" class=3D"m_17=
18169008803030191styled-by-prettify"> factor</span><span style=3D"color:#66=
0" class=3D"m_1718169008803030191styled-by-prettify">)</span><span style=3D=
"color:#000" class=3D"m_1718169008803030191styled-by-prettify"><br>=C2=A0 <=
/span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pr=
ettify">{</span><span style=3D"color:#000" class=3D"m_1718169008803030191st=
yled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=
=3D"m_1718169008803030191styled-by-prettify">return</span><span style=3D"co=
lor:#660" class=3D"m_1718169008803030191styled-by-prettify">(</span><span s=
tyle=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify">i </s=
pan><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pret=
tify">-</span><span style=3D"color:#000" class=3D"m_1718169008803030191styl=
ed-by-prettify"> </span><span style=3D"color:#660" class=3D"m_1718169008803=
030191styled-by-prettify">(</span><span style=3D"color:#000" class=3D"m_171=
8169008803030191styled-by-prettify">i </span><span style=3D"color:#660" cla=
ss=3D"m_1718169008803030191styled-by-prettify">%</span><span style=3D"color=
:#000" class=3D"m_1718169008803030191styled-by-prettify"> factor</span><spa=
n style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">.<=
/span><span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-pr=
ettify">value</span><span style=3D"color:#660" class=3D"m_17181690088030301=
91styled-by-prettify">));</span><span style=3D"color:#000" class=3D"m_17181=
69008803030191styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:#6=
60" class=3D"m_1718169008803030191styled-by-prettify">}</span><span style=
=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"><br><br><=
br></span><span style=3D"color:#008" class=3D"m_1718169008803030191styled-b=
y-prettify">static_assert</span><span style=3D"color:#660" class=3D"m_17181=
69008803030191styled-by-prettify">(</span><span style=3D"color:#066" class=
=3D"m_1718169008803030191styled-by-prettify">9</span><span style=3D"color:#=
000" class=3D"m_1718169008803030191styled-by-prettify"> </span><span style=
=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">/</span><=
span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"=
> mround</span><span style=3D"color:#660" class=3D"m_1718169008803030191sty=
led-by-prettify">(</span><span style=3D"color:#066" class=3D"m_171816900880=
3030191styled-by-prettify">5</span><span style=3D"color:#660" class=3D"m_17=
18169008803030191styled-by-prettify">)</span><span style=3D"color:#000" cla=
ss=3D"m_1718169008803030191styled-by-prettify"> </span><span style=3D"color=
:#660" class=3D"m_1718169008803030191styled-by-prettify">=3D=3D</span><span=
 style=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> </=
span><span style=3D"color:#066" class=3D"m_1718169008803030191styled-by-pre=
ttify">2</span><span style=3D"color:#660" class=3D"m_1718169008803030191sty=
led-by-prettify">,</span><span style=3D"color:#000" class=3D"m_171816900880=
3030191styled-by-prettify"> </span><span style=3D"color:#080" class=3D"m_17=
18169008803030191styled-by-prettify">&quot;&quot;</span><span style=3D"colo=
r:#660" class=3D"m_1718169008803030191styled-by-prettify">);</span><span st=
yle=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"><br></=
span><span style=3D"color:#008" class=3D"m_1718169008803030191styled-by-pre=
ttify">static_assert</span><span style=3D"color:#660" class=3D"m_1718169008=
803030191styled-by-prettify">(</span><span style=3D"color:#066" class=3D"m_=
1718169008803030191styled-by-prettify">10</span><span style=3D"color:#000" =
class=3D"m_1718169008803030191styled-by-prettify"> </span><span style=3D"co=
lor:#660" class=3D"m_1718169008803030191styled-by-prettify">/</span><span s=
tyle=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> mrou=
nd</span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by=
-prettify">(</span><span style=3D"color:#066" class=3D"m_171816900880303019=
1styled-by-prettify">5</span><span style=3D"color:#660" class=3D"m_17181690=
08803030191styled-by-prettify">)</span><span style=3D"color:#000" class=3D"=
m_1718169008803030191styled-by-prettify"> </span><span style=3D"color:#660"=
 class=3D"m_1718169008803030191styled-by-prettify">=3D=3D</span><span style=
=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> </span><=
span style=3D"color:#066" class=3D"m_1718169008803030191styled-by-prettify"=
>2</span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by=
-prettify">,</span><span style=3D"color:#000" class=3D"m_171816900880303019=
1styled-by-prettify"> </span><span style=3D"color:#080" class=3D"m_17181690=
08803030191styled-by-prettify">&quot;&quot;</span><span style=3D"color:#660=
" class=3D"m_1718169008803030191styled-by-prettify">);</span><span style=3D=
"color:#000" class=3D"m_1718169008803030191styled-by-prettify"><br></span><=
span style=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify"=
>static_assert</span><span style=3D"color:#660" class=3D"m_1718169008803030=
191styled-by-prettify">(</span><span style=3D"color:#066" class=3D"m_171816=
9008803030191styled-by-prettify">11</span><span style=3D"color:#000" class=
=3D"m_1718169008803030191styled-by-prettify"> </span><span style=3D"color:#=
660" class=3D"m_1718169008803030191styled-by-prettify">/</span><span style=
=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> mround</=
span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pre=
ttify">(</span><span style=3D"color:#066" class=3D"m_1718169008803030191sty=
led-by-prettify">5</span><span style=3D"color:#660" class=3D"m_171816900880=
3030191styled-by-prettify">)</span><span style=3D"color:#000" class=3D"m_17=
18169008803030191styled-by-prettify"> </span><span style=3D"color:#660" cla=
ss=3D"m_1718169008803030191styled-by-prettify">=3D=3D</span><span style=3D"=
color:#000" class=3D"m_1718169008803030191styled-by-prettify"> </span><span=
 style=3D"color:#066" class=3D"m_1718169008803030191styled-by-prettify">3</=
span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pre=
ttify">,</span><span style=3D"color:#000" class=3D"m_1718169008803030191sty=
led-by-prettify"> </span><span style=3D"color:#080" class=3D"m_171816900880=
3030191styled-by-prettify">&quot;&quot;</span><span style=3D"color:#660" cl=
ass=3D"m_1718169008803030191styled-by-prettify">);</span><span style=3D"col=
or:#000" class=3D"m_1718169008803030191styled-by-prettify"><br><br><br></sp=
an><span style=3D"color:#008" class=3D"m_1718169008803030191styled-by-prett=
ify">static_assert</span><span style=3D"color:#660" class=3D"m_171816900880=
3030191styled-by-prettify">(</span><span style=3D"color:#066" class=3D"m_17=
18169008803030191styled-by-prettify">9</span><span style=3D"color:#000" cla=
ss=3D"m_1718169008803030191styled-by-prettify"> </span><span style=3D"color=
:#660" class=3D"m_1718169008803030191styled-by-prettify">+</span><span styl=
e=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> mround<=
/span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pr=
ettify">(</span><span style=3D"color:#066" class=3D"m_1718169008803030191st=
yled-by-prettify">5</span><span style=3D"color:#660" class=3D"m_17181690088=
03030191styled-by-prettify">)</span><span style=3D"color:#000" class=3D"m_1=
718169008803030191styled-by-prettify"> </span><span style=3D"color:#660" cl=
ass=3D"m_1718169008803030191styled-by-prettify">=3D=3D</span><span style=3D=
"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> </span><spa=
n style=3D"color:#066" class=3D"m_1718169008803030191styled-by-prettify">10=
</span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-p=
rettify">,</span><span style=3D"color:#000" class=3D"m_1718169008803030191s=
tyled-by-prettify"> </span><span style=3D"color:#080" class=3D"m_1718169008=
803030191styled-by-prettify">&quot;&quot;</span><span style=3D"color:#660" =
class=3D"m_1718169008803030191styled-by-prettify">);</span><span style=3D"c=
olor:#000" class=3D"m_1718169008803030191styled-by-prettify"><br></span><sp=
an style=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify">s=
tatic_assert</span><span style=3D"color:#660" class=3D"m_171816900880303019=
1styled-by-prettify">(</span><span style=3D"color:#066" class=3D"m_17181690=
08803030191styled-by-prettify">10</span><span style=3D"color:#000" class=3D=
"m_1718169008803030191styled-by-prettify"> </span><span style=3D"color:#660=
" class=3D"m_1718169008803030191styled-by-prettify">+</span><span style=3D"=
color:#000" class=3D"m_1718169008803030191styled-by-prettify"> mround</span=
><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettif=
y">(</span><span style=3D"color:#066" class=3D"m_1718169008803030191styled-=
by-prettify">5</span><span style=3D"color:#660" class=3D"m_1718169008803030=
191styled-by-prettify">)</span><span style=3D"color:#000" class=3D"m_171816=
9008803030191styled-by-prettify"> </span><span style=3D"color:#660" class=
=3D"m_1718169008803030191styled-by-prettify">=3D=3D</span><span style=3D"co=
lor:#000" class=3D"m_1718169008803030191styled-by-prettify"> </span><span s=
tyle=3D"color:#066" class=3D"m_1718169008803030191styled-by-prettify">10</s=
pan><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pret=
tify">,</span><span style=3D"color:#000" class=3D"m_1718169008803030191styl=
ed-by-prettify"> </span><span style=3D"color:#080" class=3D"m_1718169008803=
030191styled-by-prettify">&quot;&quot;</span><span style=3D"color:#660" cla=
ss=3D"m_1718169008803030191styled-by-prettify">);</span><span style=3D"colo=
r:#000" class=3D"m_1718169008803030191styled-by-prettify"><br></span><span =
style=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify">stat=
ic_assert</span><span style=3D"color:#660" class=3D"m_1718169008803030191st=
yled-by-prettify">(</span><span style=3D"color:#066" class=3D"m_17181690088=
03030191styled-by-prettify">11</span><span style=3D"color:#000" class=3D"m_=
1718169008803030191styled-by-prettify"> </span><span style=3D"color:#660" c=
lass=3D"m_1718169008803030191styled-by-prettify">+</span><span style=3D"col=
or:#000" class=3D"m_1718169008803030191styled-by-prettify"> mround</span><s=
pan style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">=
(</span><span style=3D"color:#066" class=3D"m_1718169008803030191styled-by-=
prettify">5</span><span style=3D"color:#660" class=3D"m_1718169008803030191=
styled-by-prettify">)</span><span style=3D"color:#000" class=3D"m_171816900=
8803030191styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m=
_1718169008803030191styled-by-prettify">=3D=3D</span><span style=3D"color:#=
000" class=3D"m_1718169008803030191styled-by-prettify"> </span><span style=
=3D"color:#066" class=3D"m_1718169008803030191styled-by-prettify">15</span>=
<span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify=
">,</span><span style=3D"color:#000" class=3D"m_1718169008803030191styled-b=
y-prettify"> </span><span style=3D"color:#080" class=3D"m_17181690088030301=
91styled-by-prettify">&quot;&quot;</span><span style=3D"color:#660" class=
=3D"m_1718169008803030191styled-by-prettify">);</span><span style=3D"color:=
#000" class=3D"m_1718169008803030191styled-by-prettify"><br><br><br></span>=
<span style=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify=
">static_assert</span><span style=3D"color:#660" class=3D"m_171816900880303=
0191styled-by-prettify">(</span><span style=3D"color:#066" class=3D"m_17181=
69008803030191styled-by-prettify">9</span><span style=3D"color:#000" class=
=3D"m_1718169008803030191styled-by-prettify"> </span><span style=3D"color:#=
660" class=3D"m_1718169008803030191styled-by-prettify">-</span><span style=
=3D"color:#000" class=3D"m_1718169008803030191styled-by-prettify"> mround</=
span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pre=
ttify">(</span><span style=3D"color:#066" class=3D"m_1718169008803030191sty=
led-by-prettify">5</span><span style=3D"color:#660" class=3D"m_171816900880=
3030191styled-by-prettify">)</span><span style=3D"color:#000" class=3D"m_17=
18169008803030191styled-by-prettify"> </span><span style=3D"color:#660" cla=
ss=3D"m_1718169008803030191styled-by-prettify">=3D=3D</span><span style=3D"=
color:#000" class=3D"m_1718169008803030191styled-by-prettify"> </span><span=
 style=3D"color:#066" class=3D"m_1718169008803030191styled-by-prettify">5</=
span><span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-pre=
ttify">,</span><span style=3D"color:#000" class=3D"m_1718169008803030191sty=
led-by-prettify"> </span><span style=3D"color:#080" class=3D"m_171816900880=
3030191styled-by-prettify">&quot;&quot;</span><span style=3D"color:#660" cl=
ass=3D"m_1718169008803030191styled-by-prettify">);</span><span style=3D"col=
or:#000" class=3D"m_1718169008803030191styled-by-prettify"><br></span><span=
 style=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify">sta=
tic_assert</span><span style=3D"color:#660" class=3D"m_1718169008803030191s=
tyled-by-prettify">(</span><span style=3D"color:#066" class=3D"m_1718169008=
803030191styled-by-prettify">10</span><span style=3D"color:#000" class=3D"m=
_1718169008803030191styled-by-prettify"> </span><span style=3D"color:#660" =
class=3D"m_1718169008803030191styled-by-prettify">-</span><span style=3D"co=
lor:#000" class=3D"m_1718169008803030191styled-by-prettify"> mround</span><=
span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify"=
>(</span><span style=3D"color:#066" class=3D"m_1718169008803030191styled-by=
-prettify">5</span><span style=3D"color:#660" class=3D"m_171816900880303019=
1styled-by-prettify">)</span><span style=3D"color:#000" class=3D"m_17181690=
08803030191styled-by-prettify"> </span><span style=3D"color:#660" class=3D"=
m_1718169008803030191styled-by-prettify">=3D=3D</span><span style=3D"color:=
#000" class=3D"m_1718169008803030191styled-by-prettify"> </span><span style=
=3D"color:#066" class=3D"m_1718169008803030191styled-by-prettify">10</span>=
<span style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify=
">,</span><span style=3D"color:#000" class=3D"m_1718169008803030191styled-b=
y-prettify"> </span><span style=3D"color:#080" class=3D"m_17181690088030301=
91styled-by-prettify">&quot;&quot;</span><span style=3D"color:#660" class=
=3D"m_1718169008803030191styled-by-prettify">);</span><span style=3D"color:=
#000" class=3D"m_1718169008803030191styled-by-prettify"><br></span><span st=
yle=3D"color:#008" class=3D"m_1718169008803030191styled-by-prettify">static=
_assert</span><span style=3D"color:#660" class=3D"m_1718169008803030191styl=
ed-by-prettify">(</span><span style=3D"color:#066" class=3D"m_1718169008803=
030191styled-by-prettify">11</span><span style=3D"color:#000" class=3D"m_17=
18169008803030191styled-by-prettify"> </span><span style=3D"color:#660" cla=
ss=3D"m_1718169008803030191styled-by-prettify">-</span><span style=3D"color=
:#000" class=3D"m_1718169008803030191styled-by-prettify"> mround</span><spa=
n style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">(<=
/span><span style=3D"color:#066" class=3D"m_1718169008803030191styled-by-pr=
ettify">5</span><span style=3D"color:#660" class=3D"m_1718169008803030191st=
yled-by-prettify">)</span><span style=3D"color:#000" class=3D"m_17181690088=
03030191styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_1=
718169008803030191styled-by-prettify">=3D=3D</span><span style=3D"color:#00=
0" class=3D"m_1718169008803030191styled-by-prettify"> </span><span style=3D=
"color:#066" class=3D"m_1718169008803030191styled-by-prettify">10</span><sp=
an style=3D"color:#660" class=3D"m_1718169008803030191styled-by-prettify">,=
</span><span style=3D"color:#000" class=3D"m_1718169008803030191styled-by-p=
rettify"> </span><span style=3D"color:#080" class=3D"m_1718169008803030191s=
tyled-by-prettify">&quot;&quot;</span><span style=3D"color:#660" class=3D"m=
_1718169008803030191styled-by-prettify">);</span><span class=3D"HOEnZb"><fo=
nt color=3D"#888888"><span style=3D"color:#000" class=3D"m_1718169008803030=
191styled-by-prettify"><br></span><span style=3D"color:#000" class=3D"m_171=
8169008803030191styled-by-prettify"><br></span></font></span></div></code><=
/div><span class=3D"HOEnZb"><font color=3D"#888888"><div><br><br></div></fo=
nt></span></div><span class=3D"HOEnZb"><font color=3D"#888888">

<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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/1af197bf-4e85-4e4b-9486-dd7ca150c139%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/1af1=
97bf-4e85-4e4b-<wbr>9486-dd7ca150c139%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><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/CAOkZZiHVe-3-jfGOcYgrwFVksPRwrRZK7__G=
%3Ds-01Def-qTZiQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOkZZiHVe-3-jf=
GOcYgrwFVksPRwrRZK7__G%3Ds-01Def-qTZiQ%40mail.gmail.com</a>.<br />

--089e013d18c03f41b90543364794--

.


Author: "'Walt Karas' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Fri, 9 Dec 2016 08:30:40 -0800 (PST)
Raw View
------=_Part_707_1846351040.1481301040867
Content-Type: multipart/alternative;
 boundary="----=_Part_708_46514490.1481301040869"

------=_Part_708_46514490.1481301040869
Content-Type: text/plain; charset=UTF-8

I take your point, it has validity.  But round_up_to_multiple(Integral,
Integral) has issues for people like me who don't have good memories.
 Specifically, having two parameters of the same type (that are not
commutative).  I would likely be constantly looking up the right parameter
order.  And if I ddin't look it up and got it wrong, that would be a
run-time bug, potentially one that was very hard to find.

On Friday, December 9, 2016 at 4:21:28 AM UTC-5, Dawid Pilarski wrote:
>
> I do not quite like the idea of operator + and operator -. It's kind of
> misleading, that operator + and - has so strange meaning. Why not doing
> just simple function round_up_to_multiple, which would have cleaner
> interface?
>
>
> 2016-12-08 19:39 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future
> Proposals <std-pr...@isocpp.org <javascript:>>:
>
>> #include <type_traits>
>>
>>
>> template <typename I>
>> struct mround_type
>>   {
>>     static_assert(
>>       std::is_integral<I>::value, "mround_type requires integral type");
>>
>>
>>     const I value;
>>
>>
>>     constexpr explicit mround_type(I v) : value(v) { }
>>   };
>>
>>
>> template <typename I>
>> constexpr auto mround(I i)
>>   {
>>     static_assert(
>>       std::is_integral<I>::value,
>>       "mround() parameter must be of integral type");
>>
>>
>>     return(mround_type<I>(i));
>>   }
>>
>>
>> // Rounded-up integral division.
>> template <typename I>
>> constexpr I operator / (I i, mround_type<I> factor)
>>   {
>>     return((i + factor.value - 1) / factor.value);
>>   }
>>
>>
>> // Round up integer to multiple.
>> template <typename I>
>> constexpr I operator + (I i, mround_type<I> factor)
>>   {
>>     return((i / factor) * factor.value);
>>   }
>>
>>
>> // Round down integer to multiple.
>> template <typename I>
>> constexpr I operator - (I i, mround_type<I> factor)
>>   {
>>     return(i - (i % factor.value));
>>   }
>>
>>
>> static_assert(9 / mround(5) == 2, "");
>> static_assert(10 / mround(5) == 2, "");
>> static_assert(11 / mround(5) == 3, "");
>>
>>
>> static_assert(9 + mround(5) == 10, "");
>> static_assert(10 + mround(5) == 10, "");
>> static_assert(11 + mround(5) == 15, "");
>>
>>
>> static_assert(9 - mround(5) == 5, "");
>> static_assert(10 - mround(5) == 10, "");
>> static_assert(11 - mround(5) == 10, "");
>>
>>
>>
>> --
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium=email&utm_source=footer>
>> .
>>
>
>

--
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/68a234d9-62db-4839-a7e0-89702819a9f5%40isocpp.org.

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

<div dir=3D"ltr">I take your point, it has validity. =C2=A0But round_up_to_=
multiple(Integral, Integral) has issues for people like me who don&#39;t ha=
ve good memories. =C2=A0Specifically, having two parameters of the same typ=
e (that are not commutative). =C2=A0I would likely be constantly looking up=
 the right parameter order. =C2=A0And if I ddin&#39;t look it up and got it=
 wrong, that would be a run-time bug, potentially one that was very hard to=
 find.<br><br>On Friday, December 9, 2016 at 4:21:28 AM UTC-5, Dawid Pilars=
ki 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"><cod=
e>I do not quite like the idea of operator + and operator -. It&#39;s kind =
of misleading, that operator + and - has so strange meaning. Why not doing =
just simple function round_up_to_multiple, which would have cleaner interfa=
ce?</code><code><span style=3D"color:rgb(0,0,0)"><br><br></span></code></di=
v><div><br><div class=3D"gmail_quote">2016-12-08 19:39 GMT+01:00 &#39;Walt =
Karas&#39; via ISO C++ Standard - Future Proposals <span dir=3D"ltr">&lt;<a=
 href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"W8rCBJ8xCA=
AJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;retur=
n true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;">std-pr.=
...@isocpp.org</a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D=
"ltr"><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,=
187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code><d=
iv><span style=3D"color:#800">#include</span><span style=3D"color:#000"> </=
span><span style=3D"color:#080">&lt;type_traits&gt;</span><span style=3D"co=
lor:#000"><br><br><br></span><span style=3D"color:#008">template</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span =
style=3D"color:#008">typename</span><span style=3D"color:#000"> I</span><sp=
an style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#008">struct</span><span style=3D"color:#000"> mround_ty=
pe<br>=C2=A0 </span><span style=3D"color:#660">{</span><span style=3D"color=
:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">static_assert</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=
=3D"color:#000">is_integral</span><span style=3D"color:#660">&lt;</span><sp=
an style=3D"color:#000">I</span><span style=3D"color:#660">&gt;::</span><sp=
an style=3D"color:#000">value</span><span style=3D"color:#660">,</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#080">&quot;mround_type=
 requires integral type&quot;</span><span style=3D"color:#660">);</span><sp=
an style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"col=
or:#008">const</span><span style=3D"color:#000"> I value</span><span style=
=3D"color:#660">;</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#008">constexpr</span><span style=3D"color:=
#000"> </span><span style=3D"color:#008">explicit</span><span style=3D"colo=
r:#000"> mround_type</span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">I v</span><span style=3D"color:#660">)</span><span style=3D=
"color:#000"> </span><span style=3D"color:#660">:</span><span style=3D"colo=
r:#000"> value</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#000">v</span><span style=3D"color:#660">)</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>=C2=
=A0 </span><span style=3D"color:#660">};</span><span style=3D"color:#000"><=
br><br><br></span><span style=3D"color:#008">template</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660">&lt;</span><span style=3D"co=
lor:#008">typename</span><span style=3D"color:#000"> I</span><span style=3D=
"color:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">constexpr</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#008">auto</span><span style=3D"color:#000"> mround</span><spa=
n style=3D"color:#660">(</span><span style=3D"color:#000">I i</span><span s=
tyle=3D"color:#660">)</span><span style=3D"color:#000"><br>=C2=A0 </span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#008">static_assert</span><span style=3D"co=
lor:#660">(</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 std</=
span><span style=3D"color:#660">::</span><span style=3D"color:#000">is_inte=
gral</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000"=
>I</span><span style=3D"color:#660">&gt;::</span><span style=3D"color:#000"=
>value</span><span style=3D"color:#660">,</span><span style=3D"color:#000">=
<br>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#080">&quot;mround() p=
arameter must be of integral type&quot;</span><span style=3D"color:#660">);=
</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color:#008">return</span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#000">mround_type</span><span style=3D"color:#660">&lt;</span>=
<span style=3D"color:#000">I</span><span style=3D"color:#660">&gt;(</span><=
span style=3D"color:#000">i</span><span style=3D"color:#660">));</span><spa=
n style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">}</span=
><span style=3D"color:#000"><br><br><br></span><span style=3D"color:#800">/=
/ Rounded-up integral division.</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#008">template</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">&lt;</span><span style=3D"color:#008">typenam=
e</span><span style=3D"color:#000"> I</span><span style=3D"color:#660">&gt;=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">con=
stexpr</span><span style=3D"color:#000"> I </span><span style=3D"color:#008=
">operator</span><span style=3D"color:#000"> </span><span style=3D"color:#6=
60">/</span><span style=3D"color:#000"> </span><span style=3D"color:#660">(=
</span><span style=3D"color:#000">I i</span><span style=3D"color:#660">,</s=
pan><span style=3D"color:#000"> mround_type</span><span style=3D"color:#660=
">&lt;</span><span style=3D"color:#000">I</span><span style=3D"color:#660">=
&gt;</span><span style=3D"color:#000"> factor</span><span style=3D"color:#6=
60">)</span><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"col=
or:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span =
style=3D"color:#008">return</span><span style=3D"color:#660">((</span><span=
 style=3D"color:#000">i </span><span style=3D"color:#660">+</span><span sty=
le=3D"color:#000"> factor</span><span style=3D"color:#660">.</span><span st=
yle=3D"color:#000">value </span><span style=3D"color:#660">-</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#066">1</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">/</span><span style=3D"color:#000"> factor</span><span style=3D"=
color:#660">.</span><span style=3D"color:#000">value</span><span style=3D"c=
olor:#660">);</span><span style=3D"color:#000"><br>=C2=A0 </span><span styl=
e=3D"color:#660">}</span><span style=3D"color:#000"><br><br><br></span><spa=
n style=3D"color:#800">// Round up integer to multiple.</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">template</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span st=
yle=3D"color:#008">typename</span><span style=3D"color:#000"> I</span><span=
 style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#008">constexpr</span><span style=3D"color:#000"> I </span=
><span style=3D"color:#008">operator</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">+</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#000">I i</span><span=
 style=3D"color:#660">,</span><span style=3D"color:#000"> mround_type</span=
><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</span><=
span style=3D"color:#660">&gt;</span><span style=3D"color:#000"> factor</sp=
an><span style=3D"color:#660">)</span><span style=3D"color:#000"><br>=C2=A0=
 </span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span style=3D=
"color:#660">((</span><span style=3D"color:#000">i </span><span style=3D"co=
lor:#660">/</span><span style=3D"color:#000"> factor</span><span style=3D"c=
olor:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:=
#660">*</span><span style=3D"color:#000"> factor</span><span style=3D"color=
:#660">.</span><span style=3D"color:#000">value</span><span style=3D"color:=
#660">);</span><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"=
color:#660">}</span><span style=3D"color:#000"><br><br><br></span><span sty=
le=3D"color:#800">// Round down integer to multiple.</span><span style=3D"c=
olor:#000"><br></span><span style=3D"color:#008">template</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span style=
=3D"color:#008">typename</span><span style=3D"color:#000"> I</span><span st=
yle=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><span s=
tyle=3D"color:#008">constexpr</span><span style=3D"color:#000"> I </span><s=
pan style=3D"color:#008">operator</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">-</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">I i</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000"> mround_type</span><s=
pan style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</span><spa=
n style=3D"color:#660">&gt;</span><span style=3D"color:#000"> factor</span>=
<span style=3D"color:#660">)</span><span style=3D"color:#000"><br>=C2=A0 </=
span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span style=3D"co=
lor:#660">(</span><span style=3D"color:#000">i </span><span style=3D"color:=
#660">-</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
>(</span><span style=3D"color:#000">i </span><span style=3D"color:#660">%</=
span><span style=3D"color:#000"> factor</span><span style=3D"color:#660">.<=
/span><span style=3D"color:#000">value</span><span style=3D"color:#660">));=
</span><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#6=
60">}</span><span style=3D"color:#000"><br><br><br></span><span style=3D"co=
lor:#008">static_assert</span><span style=3D"color:#660">(</span><span styl=
e=3D"color:#066">9</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">/</span><span style=3D"color:#000"> mround</span><span style=3D=
"color:#660">(</span><span style=3D"color:#066">5</span><span style=3D"colo=
r:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#06=
6">2</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#6=
60">);</span><span style=3D"color:#000"><br></span><span style=3D"color:#00=
8">static_assert</span><span style=3D"color:#660">(</span><span style=3D"co=
lor:#066">10</span><span style=3D"color:#000"> </span><span style=3D"color:=
#660">/</span><span style=3D"color:#000"> mround</span><span style=3D"color=
:#660">(</span><span style=3D"color:#066">5</span><span style=3D"color:#660=
">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D=
=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#066">2</=
span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#660">);=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">sta=
tic_assert</span><span style=3D"color:#660">(</span><span style=3D"color:#0=
66">11</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
/</span><span style=3D"color:#000"> mround</span><span style=3D"color:#660"=
>(</span><span style=3D"color:#066">5</span><span style=3D"color:#660">)</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#066">3</span><=
span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span =
style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#660">);</span=
><span style=3D"color:#000"><br><br><br></span><span style=3D"color:#008">s=
tatic_assert</span><span style=3D"color:#660">(</span><span style=3D"color:=
#066">9</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
>+</span><span style=3D"color:#000"> mround</span><span style=3D"color:#660=
">(</span><span style=3D"color:#066">5</span><span style=3D"color:#660">)</=
span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D</=
span><span style=3D"color:#000"> </span><span style=3D"color:#066">10</span=
><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#660">);</sp=
an><span style=3D"color:#000"><br></span><span style=3D"color:#008">static_=
assert</span><span style=3D"color:#660">(</span><span style=3D"color:#066">=
10</span><span style=3D"color:#000"> </span><span style=3D"color:#660">+</s=
pan><span style=3D"color:#000"> mround</span><span style=3D"color:#660">(</=
span><span style=3D"color:#066">5</span><span style=3D"color:#660">)</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#066">10</span><spa=
n style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#080">&quot;&quot;</span><span style=3D"color:#660">);</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#008">static_asser=
t</span><span style=3D"color:#660">(</span><span style=3D"color:#066">11</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#660">+</span><=
span style=3D"color:#000"> mround</span><span style=3D"color:#660">(</span>=
<span style=3D"color:#066">5</span><span style=3D"color:#660">)</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#066">15</span><span sty=
le=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D=
"color:#080">&quot;&quot;</span><span style=3D"color:#660">);</span><span s=
tyle=3D"color:#000"><br><br><br></span><span style=3D"color:#008">static_as=
sert</span><span style=3D"color:#660">(</span><span style=3D"color:#066">9<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">-</span=
><span style=3D"color:#000"> mround</span><span style=3D"color:#660">(</spa=
n><span style=3D"color:#066">5</span><span style=3D"color:#660">)</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#066">5</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=
=3D"color:#080">&quot;&quot;</span><span style=3D"color:#660">);</span><spa=
n style=3D"color:#000"><br></span><span style=3D"color:#008">static_assert<=
/span><span style=3D"color:#660">(</span><span style=3D"color:#066">10</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#660">-</span><sp=
an style=3D"color:#000"> mround</span><span style=3D"color:#660">(</span><s=
pan style=3D"color:#066">5</span><span style=3D"color:#660">)</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#066">10</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#080">&quot;&quot;</span><span style=3D"color:#660">);</span><span sty=
le=3D"color:#000"><br></span><span style=3D"color:#008">static_assert</span=
><span style=3D"color:#660">(</span><span style=3D"color:#066">11</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">-</span><span st=
yle=3D"color:#000"> mround</span><span style=3D"color:#660">(</span><span s=
tyle=3D"color:#066">5</span><span style=3D"color:#660">)</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D</span><span style=
=3D"color:#000"> </span><span style=3D"color:#066">10</span><span style=3D"=
color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color=
:#080">&quot;&quot;</span><span style=3D"color:#660">);</span><span><font c=
olor=3D"#888888"><span style=3D"color:#000"><br></span><span style=3D"color=
:#000"><br></span></font></span></div></code></div><span><font color=3D"#88=
8888"><div><br><br></div></font></span></div><span><font color=3D"#888888">

<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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
W8rCBJ8xCAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"W8rCBJ8xCAAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@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/1af197bf-4e85-4e4b-9486-dd7ca150c139%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/1af197bf-4e85-4e4b-<wbr>9486-=
dd7ca150c139%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br></div>
</blockquote></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/68a234d9-62db-4839-a7e0-89702819a9f5%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/68a234d9-62db-4839-a7e0-89702819a9f5=
%40isocpp.org</a>.<br />

------=_Part_708_46514490.1481301040869--

------=_Part_707_1846351040.1481301040867--

.


Author: "'Walt Karas' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Fri, 9 Dec 2016 08:44:56 -0800 (PST)
Raw View
------=_Part_648_332652123.1481301896541
Content-Type: multipart/alternative;
 boundary="----=_Part_649_1257731452.1481301896542"

------=_Part_649_1257731452.1481301896542
Content-Type: text/plain; charset=UTF-8

A possible compromise would be:

Integral round_up_to_multiple(Integral i, mround_type<Integral> factor)

and also remove the explicit from mround_type's constructor.  Then people
with bad memories could write round_up_to_multiple(9, mround(5)).  But for
round_up_to_multiple(9, 5) to compile (for those with good memories), the
compiler would have to search std for an implicit conversion for 5 based on
the function being in std.  And, it would have to specialize templates as a
part of the search.   Probably doesn't work that way.

On Friday, December 9, 2016 at 11:30:40 AM UTC-5, Walt Karas wrote:
>
> I take your point, it has validity.  But round_up_to_multiple(Integral,
> Integral) has issues for people like me who don't have good memories.
>  Specifically, having two parameters of the same type (that are not
> commutative).  I would likely be constantly looking up the right parameter
> order.  And if I ddin't look it up and got it wrong, that would be a
> run-time bug, potentially one that was very hard to find.
>
> On Friday, December 9, 2016 at 4:21:28 AM UTC-5, Dawid Pilarski wrote:
>>
>> I do not quite like the idea of operator + and operator -. It's kind of
>> misleading, that operator + and - has so strange meaning. Why not doing
>> just simple function round_up_to_multiple, which would have cleaner
>> interface?
>>
>>
>> 2016-12-08 19:39 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future
>> Proposals <std-pr...@isocpp.org>:
>>
>>> #include <type_traits>
>>>
>>>
>>> template <typename I>
>>> struct mround_type
>>>   {
>>>     static_assert(
>>>       std::is_integral<I>::value, "mround_type requires integral type");
>>>
>>>
>>>     const I value;
>>>
>>>
>>>     constexpr explicit mround_type(I v) : value(v) { }
>>>   };
>>>
>>>
>>> template <typename I>
>>> constexpr auto mround(I i)
>>>   {
>>>     static_assert(
>>>       std::is_integral<I>::value,
>>>       "mround() parameter must be of integral type");
>>>
>>>
>>>     return(mround_type<I>(i));
>>>   }
>>>
>>>
>>> // Rounded-up integral division.
>>> template <typename I>
>>> constexpr I operator / (I i, mround_type<I> factor)
>>>   {
>>>     return((i + factor.value - 1) / factor.value);
>>>   }
>>>
>>>
>>> // Round up integer to multiple.
>>> template <typename I>
>>> constexpr I operator + (I i, mround_type<I> factor)
>>>   {
>>>     return((i / factor) * factor.value);
>>>   }
>>>
>>>
>>> // Round down integer to multiple.
>>> template <typename I>
>>> constexpr I operator - (I i, mround_type<I> factor)
>>>   {
>>>     return(i - (i % factor.value));
>>>   }
>>>
>>>
>>> static_assert(9 / mround(5) == 2, "");
>>> static_assert(10 / mround(5) == 2, "");
>>> static_assert(11 / mround(5) == 3, "");
>>>
>>>
>>> static_assert(9 + mround(5) == 10, "");
>>> static_assert(10 + mround(5) == 10, "");
>>> static_assert(11 + mround(5) == 15, "");
>>>
>>>
>>> static_assert(9 - mround(5) == 5, "");
>>> static_assert(10 - mround(5) == 10, "");
>>> static_assert(11 - mround(5) == 10, "");
>>>
>>>
>>>
>>> --
>>> 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-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> To view this discussion on the web visit
>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>

--
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/a6a6c2ed-55eb-4fb2-a0b8-381d8c087650%40isocpp.org.

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

<div dir=3D"ltr">A possible compromise would be:<div><br></div><div>Integra=
l round_up_to_multiple(Integral i, mround_type&lt;Integral&gt; factor)</div=
><div><br></div><div>and also remove the explicit from mround_type&#39;s co=
nstructor. =C2=A0Then people with bad memories could write round_up_to_mult=
iple(9, mround(5)). =C2=A0But for round_up_to_multiple(9, 5) to compile (fo=
r those with good memories), the compiler would have to search std for an i=
mplicit conversion for 5 based on the function being in std. =C2=A0And, it =
would have to specialize templates as a part of the search. =C2=A0 Probably=
 doesn&#39;t work that way.<br><br>On Friday, December 9, 2016 at 11:30:40 =
AM UTC-5, Walt Karas wrote:<blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v dir=3D"ltr">I take your point, it has validity. =C2=A0But round_up_to_mul=
tiple(Integral, Integral) has issues for people like me who don&#39;t have =
good memories. =C2=A0Specifically, having two parameters of the same type (=
that are not commutative). =C2=A0I would likely be constantly looking up th=
e right parameter order. =C2=A0And if I ddin&#39;t look it up and got it wr=
ong, that would be a run-time bug, potentially one that was very hard to fi=
nd.<br><br>On Friday, December 9, 2016 at 4:21:28 AM UTC-5, Dawid Pilarski =
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"><code>I do n=
ot quite like the idea of operator + and operator -. It&#39;s kind of misle=
ading, that operator + and - has so strange meaning. Why not doing just sim=
ple function round_up_to_multiple, which would have cleaner interface?</cod=
e><code><span style=3D"color:rgb(0,0,0)"><br><br></span></code></div><div><=
br><div class=3D"gmail_quote">2016-12-08 19:39 GMT+01:00 &#39;Walt Karas&#3=
9; via ISO C++ Standard - Future Proposals <span dir=3D"ltr">&lt;<a rel=3D"=
nofollow">std-pr...@isocpp.org</a>&gt;</span>:<br><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"><div style=3D"background-color:rgb(250,250,250);bord=
er-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:bre=
ak-word"><code><div><span style=3D"color:#800">#include</span><span style=
=3D"color:#000"> </span><span style=3D"color:#080">&lt;type_traits&gt;</spa=
n><span style=3D"color:#000"><br><br><br></span><span style=3D"color:#008">=
template</span><span style=3D"color:#000"> </span><span style=3D"color:#660=
">&lt;</span><span style=3D"color:#008">typename</span><span style=3D"color=
:#000"> I</span><span style=3D"color:#660">&gt;</span><span style=3D"color:=
#000"><br></span><span style=3D"color:#008">struct</span><span style=3D"col=
or:#000"> mround_type<br>=C2=A0 </span><span style=3D"color:#660">{</span><=
span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#00=
8">static_assert</span><span style=3D"color:#660">(</span><span style=3D"co=
lor:#000"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"color:#660">::<=
/span><span style=3D"color:#000">is_integral</span><span style=3D"color:#66=
0">&lt;</span><span style=3D"color:#000">I</span><span style=3D"color:#660"=
>&gt;::</span><span style=3D"color:#000">value</span><span style=3D"color:#=
660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#080">=
&quot;mround_type requires integral type&quot;</span><span style=3D"color:#=
660">);</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><=
span style=3D"color:#008">const</span><span style=3D"color:#000"> I value</=
span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br><br>=
<br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">constexpr</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#008">explicit</span><span=
 style=3D"color:#000"> mround_type</span><span style=3D"color:#660">(</span=
><span style=3D"color:#000">I v</span><span style=3D"color:#660">)</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">:</span><span s=
tyle=3D"color:#000"> value</span><span style=3D"color:#660">(</span><span s=
tyle=3D"color:#000">v</span><span style=3D"color:#660">)</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">{</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">}</span><span style=3D"color:=
#000"><br>=C2=A0 </span><span style=3D"color:#660">};</span><span style=3D"=
color:#000"><br><br><br></span><span style=3D"color:#008">template</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><spa=
n style=3D"color:#008">typename</span><span style=3D"color:#000"> I</span><=
span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span>=
<span style=3D"color:#008">constexpr</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#008">auto</span><span style=3D"color:#000"> mround=
</span><span style=3D"color:#660">(</span><span style=3D"color:#000">I i</s=
pan><span style=3D"color:#660">)</span><span style=3D"color:#000"><br>=C2=
=A0 </span><span style=3D"color:#660">{</span><span style=3D"color:#000"><b=
r>=C2=A0 =C2=A0 </span><span style=3D"color:#008">static_assert</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =
=C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"color:#=
000">is_integral</span><span style=3D"color:#660">&lt;</span><span style=3D=
"color:#000">I</span><span style=3D"color:#660">&gt;::</span><span style=3D=
"color:#000">value</span><span style=3D"color:#660">,</span><span style=3D"=
color:#000"><br>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#080">&quo=
t;mround() parameter must be of integral type&quot;</span><span style=3D"co=
lor:#660">);</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </s=
pan><span style=3D"color:#008">return</span><span style=3D"color:#660">(</s=
pan><span style=3D"color:#000">mround_type</span><span style=3D"color:#660"=
>&lt;</span><span style=3D"color:#000">I</span><span style=3D"color:#660">&=
gt;(</span><span style=3D"color:#000">i</span><span style=3D"color:#660">))=
;</span><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#=
660">}</span><span style=3D"color:#000"><br><br><br></span><span style=3D"c=
olor:#800">// Rounded-up integral division.</span><span style=3D"color:#000=
"><br></span><span style=3D"color:#008">template</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">&lt;</span><span style=3D"color:#=
008">typename</span><span style=3D"color:#000"> I</span><span style=3D"colo=
r:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"col=
or:#008">constexpr</span><span style=3D"color:#000"> I </span><span style=
=3D"color:#008">operator</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">/</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">(</span><span style=3D"color:#000">I i</span><span style=3D"co=
lor:#660">,</span><span style=3D"color:#000"> mround_type</span><span style=
=3D"color:#660">&lt;</span><span style=3D"color:#000">I</span><span style=
=3D"color:#660">&gt;</span><span style=3D"color:#000"> factor</span><span s=
tyle=3D"color:#660">)</span><span style=3D"color:#000"><br>=C2=A0 </span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#008">return</span><span style=3D"color:#66=
0">((</span><span style=3D"color:#000">i </span><span style=3D"color:#660">=
+</span><span style=3D"color:#000"> factor</span><span style=3D"color:#660"=
>.</span><span style=3D"color:#000">value </span><span style=3D"color:#660"=
>-</span><span style=3D"color:#000"> </span><span style=3D"color:#066">1</s=
pan><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">/</span><span style=3D"color:#000"> factor</span>=
<span style=3D"color:#660">.</span><span style=3D"color:#000">value</span><=
span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 </=
span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br><br>=
<br></span><span style=3D"color:#800">// Round up integer to multiple.</spa=
n><span style=3D"color:#000"><br></span><span style=3D"color:#008">template=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</=
span><span style=3D"color:#008">typename</span><span style=3D"color:#000"> =
I</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#008">constexpr</span><span style=3D"color:#0=
00"> I </span><span style=3D"color:#008">operator</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">+</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">(</span><span style=3D"color:#000">I =
i</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> mrou=
nd_type</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#0=
00">I</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000=
"> factor</span><span style=3D"color:#660">)</span><span style=3D"color:#00=
0"><br>=C2=A0 </span><span style=3D"color:#660">{</span><span style=3D"colo=
r:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><s=
pan style=3D"color:#660">((</span><span style=3D"color:#000">i </span><span=
 style=3D"color:#660">/</span><span style=3D"color:#000"> factor</span><spa=
n style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">*</span><span style=3D"color:#000"> factor</span><span st=
yle=3D"color:#660">.</span><span style=3D"color:#000">value</span><span sty=
le=3D"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 </span><sp=
an style=3D"color:#660">}</span><span style=3D"color:#000"><br><br><br></sp=
an><span style=3D"color:#800">// Round down integer to multiple.</span><spa=
n style=3D"color:#000"><br></span><span style=3D"color:#008">template</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><=
span style=3D"color:#008">typename</span><span style=3D"color:#000"> I</spa=
n><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></sp=
an><span style=3D"color:#008">constexpr</span><span style=3D"color:#000"> I=
 </span><span style=3D"color:#008">operator</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">-</span><span style=3D"color:#000"> </=
span><span style=3D"color:#660">(</span><span style=3D"color:#000">I i</spa=
n><span style=3D"color:#660">,</span><span style=3D"color:#000"> mround_typ=
e</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">I<=
/span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"> fac=
tor</span><span style=3D"color:#660">)</span><span style=3D"color:#000"><br=
>=C2=A0 </span><span style=3D"color:#660">{</span><span style=3D"color:#000=
"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span st=
yle=3D"color:#660">(</span><span style=3D"color:#000">i </span><span style=
=3D"color:#660">-</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#000">i </span><span style=3D"color=
:#660">%</span><span style=3D"color:#000"> factor</span><span style=3D"colo=
r:#660">.</span><span style=3D"color:#000">value</span><span style=3D"color=
:#660">));</span><span style=3D"color:#000"><br>=C2=A0 </span><span style=
=3D"color:#660">}</span><span style=3D"color:#000"><br><br><br></span><span=
 style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</spa=
n><span style=3D"color:#066">9</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">/</span><span style=3D"color:#000"> mround</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#066">5</span><span s=
tyle=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=
=3D"color:#066">2</span><span style=3D"color:#660">,</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span styl=
e=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">static_assert</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#066">10</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">/</span><span style=3D"color:#000"> mround</span><span s=
tyle=3D"color:#660">(</span><span style=3D"color:#066">5</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#066">2</span><span style=3D"color:#660">,</span><span style=3D"color:=
#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"=
color:#660">);</span><span style=3D"color:#000"><br></span><span style=3D"c=
olor:#008">static_assert</span><span style=3D"color:#660">(</span><span sty=
le=3D"color:#066">11</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">/</span><span style=3D"color:#000"> mround</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#066">5</span><span style=3D"=
color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color=
:#066">3</span><span style=3D"color:#660">,</span><span style=3D"color:#000=
"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"colo=
r:#660">);</span><span style=3D"color:#000"><br><br><br></span><span style=
=3D"color:#008">static_assert</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#066">9</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">+</span><span style=3D"color:#000"> mround</span><span st=
yle=3D"color:#660">(</span><span style=3D"color:#066">5</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#066">10</span><span style=3D"color:#660">,</span><span style=3D"color=
:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=3D=
"color:#660">);</span><span style=3D"color:#000"><br></span><span style=3D"=
color:#008">static_assert</span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#066">10</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">+</span><span style=3D"color:#000"> mround</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#066">5</span><span style=3D"=
color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color=
:#066">10</span><span style=3D"color:#660">,</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"col=
or:#660">);</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#008">static_assert</span><span style=3D"color:#660">(</span><span style=
=3D"color:#066">11</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">+</span><span style=3D"color:#000"> mround</span><span style=3D=
"color:#660">(</span><span style=3D"color:#066">5</span><span style=3D"colo=
r:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#06=
6">15</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> =
</span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#=
660">);</span><span style=3D"color:#000"><br><br><br></span><span style=3D"=
color:#008">static_assert</span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#066">9</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">-</span><span style=3D"color:#000"> mround</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#066">5</span><span style=3D"=
color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color=
:#066">5</span><span style=3D"color:#660">,</span><span style=3D"color:#000=
"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"colo=
r:#660">);</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#008">static_assert</span><span style=3D"color:#660">(</span><span style=
=3D"color:#066">10</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">-</span><span style=3D"color:#000"> mround</span><span style=3D=
"color:#660">(</span><span style=3D"color:#066">5</span><span style=3D"colo=
r:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#06=
6">10</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> =
</span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#=
660">);</span><span style=3D"color:#000"><br></span><span style=3D"color:#0=
08">static_assert</span><span style=3D"color:#660">(</span><span style=3D"c=
olor:#066">11</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">-</span><span style=3D"color:#000"> mround</span><span style=3D"colo=
r:#660">(</span><span style=3D"color:#066">5</span><span style=3D"color:#66=
0">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#066">=
10</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#660=
">);</span><span><font color=3D"#888888"><span style=3D"color:#000"><br></s=
pan><span style=3D"color:#000"><br></span></font></span></div></code></div>=
<span><font color=3D"#888888"><div><br><br></div></font></span></div><span>=
<font color=3D"#888888">

<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 rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</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/1af197bf-4e85-4e4b-9486-dd7ca150c139%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/1af197bf-4e85-4e4b-<wbr>9486-=
dd7ca150c139%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br></div>
</blockquote></div></blockquote></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/a6a6c2ed-55eb-4fb2-a0b8-381d8c087650%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a6a6c2ed-55eb-4fb2-a0b8-381d8c087650=
%40isocpp.org</a>.<br />

------=_Part_649_1257731452.1481301896542--

------=_Part_648_332652123.1481301896541--

.


Author: Viacheslav Usov <via.usov@gmail.com>
Date: Fri, 9 Dec 2016 18:02:14 +0100
Raw View
--001a113fbe0e3d1f0305433cb7d2
Content-Type: text/plain; charset=UTF-8

On Thu, Dec 8, 2016 at 7:39 PM, 'Walt Karas' via ISO C++ Standard - Future
Proposals <std-proposals@isocpp.org> wrote:

There are two problems, which are related.

1. Your implementation of operator / is unsafe when the dividend is close
to its max value, so that (+ factor - 1) would cause an overflow. I suppose
it is for exposition only, and the real implementation should be safe,
which can always be done.

2. The behaviour of "round up" ought to be specified under similar
conditions, at least as UB; perhaps you could do better than that at least
for some integral types.

Cheers,
V.

--
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/CAA7YVg2GKXQ2CZMXR9Mvyfc%3DQKHMpmvg1oeNZc14_LT2LAtatQ%40mail.gmail.com.

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

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, Dec 8, 2016 at 7:39 PM, &#39;Walt Karas&#39; via ISO C++ Standard - Fut=
ure Proposals <span dir=3D"ltr">&lt;<a href=3D"mailto:std-proposals@isocpp.=
org" target=3D"_blank">std-proposals@isocpp.org</a>&gt;</span> wrote:</div>=
<div class=3D"gmail_quote"><br></div><div class=3D"gmail_quote">There are t=
wo problems, which are related.</div><div class=3D"gmail_quote"><br></div><=
div class=3D"gmail_quote">1. Your implementation of operator / is unsafe wh=
en the dividend is close to its max value, so that (+ factor - 1) would cau=
se an overflow. I suppose it is for exposition only, and the real implement=
ation should be safe, which can always be done.</div><div class=3D"gmail_qu=
ote"><br></div><div class=3D"gmail_quote">2. The behaviour of &quot;round u=
p&quot; ought to be specified under similar conditions, at least as UB; per=
haps you could do better than that at least for some integral types.</div><=
div class=3D"gmail_quote"><br></div><div class=3D"gmail_quote">Cheers,</div=
><div class=3D"gmail_quote">V.</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/CAA7YVg2GKXQ2CZMXR9Mvyfc%3DQKHMpmvg1o=
eNZc14_LT2LAtatQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAA7YVg2GKXQ2CZ=
MXR9Mvyfc%3DQKHMpmvg1oeNZc14_LT2LAtatQ%40mail.gmail.com</a>.<br />

--001a113fbe0e3d1f0305433cb7d2--

.


Author: "'Walt Karas' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Sat, 10 Dec 2016 13:40:54 -0800 (PST)
Raw View
------=_Part_842_339972420.1481406054161
Content-Type: multipart/alternative;
 boundary="----=_Part_843_1774367914.1481406054162"

------=_Part_843_1774367914.1481406054162
Content-Type: text/plain; charset=UTF-8

How about this alternative?

#include <type_traits>

template <typename I>
struct mround_type
  {
    static_assert(
      std::is_integral<I>::value, "mround_type requires integral type");

    const I value;

    constexpr explicit mround_type(I v) : value(v) { }

    // Rounded-up integral division.
    constexpr I div(I factor)
      {
        return((value + factor - 1) / factor);
      }

    // Round up integer to multiple.
    constexpr I up(I factor)
      {
        return(div(factor) * factor);
      }

    // Round down integer to multiple.
    constexpr I down(I factor)
      {
        return(value - (value % factor));
      }
  };

template <typename I>
constexpr auto mround(I i)
  {
    static_assert(
      std::is_integral<I>::value,
      "mround() parameter must be of integral type");

    return(mround_type<I>(i));
  }

static_assert(mround(9).div(5) == 2, "");
static_assert(mround(10).div(5) == 2, "");
static_assert(mround(11).div(5) == 3, "");

static_assert(mround(9).up(5) == 10, "");
static_assert(mround(10).up(5) == 10, "");
static_assert(mround(11).up(5) == 15, "");

static_assert(mround(9).down(5) == 5, "");
static_assert(mround(10).down(5) == 10, "");
static_assert(mround(11).down(5) == 10, "");




On Friday, December 9, 2016 at 11:30:40 AM UTC-5, Walt Karas wrote:
>
> I take your point, it has validity.  But round_up_to_multiple(Integral,
> Integral) has issues for people like me who don't have good memories.
>  Specifically, having two parameters of the same type (that are not
> commutative).  I would likely be constantly looking up the right parameter
> order.  And if I ddin't look it up and got it wrong, that would be a
> run-time bug, potentially one that was very hard to find.
>
> On Friday, December 9, 2016 at 4:21:28 AM UTC-5, Dawid Pilarski wrote:
>>
>> I do not quite like the idea of operator + and operator -. It's kind of
>> misleading, that operator + and - has so strange meaning. Why not doing
>> just simple function round_up_to_multiple, which would have cleaner
>> interface?
>>
>>
>> 2016-12-08 19:39 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future
>> Proposals <std-pr...@isocpp.org>:
>>
>>> #include <type_traits>
>>>
>>>
>>> template <typename I>
>>> struct mround_type
>>>   {
>>>     static_assert(
>>>       std::is_integral<I>::value, "mround_type requires integral type");
>>>
>>>
>>>     const I value;
>>>
>>>
>>>     constexpr explicit mround_type(I v) : value(v) { }
>>>   };
>>>
>>>
>>> template <typename I>
>>> constexpr auto mround(I i)
>>>   {
>>>     static_assert(
>>>       std::is_integral<I>::value,
>>>       "mround() parameter must be of integral type");
>>>
>>>
>>>     return(mround_type<I>(i));
>>>   }
>>>
>>>
>>> // Rounded-up integral division.
>>> template <typename I>
>>> constexpr I operator / (I i, mround_type<I> factor)
>>>   {
>>>     return((i + factor.value - 1) / factor.value);
>>>   }
>>>
>>>
>>> // Round up integer to multiple.
>>> template <typename I>
>>> constexpr I operator + (I i, mround_type<I> factor)
>>>   {
>>>     return((i / factor) * factor.value);
>>>   }
>>>
>>>
>>> // Round down integer to multiple.
>>> template <typename I>
>>> constexpr I operator - (I i, mround_type<I> factor)
>>>   {
>>>     return(i - (i % factor.value));
>>>   }
>>>
>>>
>>> static_assert(9 / mround(5) == 2, "");
>>> static_assert(10 / mround(5) == 2, "");
>>> static_assert(11 / mround(5) == 3, "");
>>>
>>>
>>> static_assert(9 + mround(5) == 10, "");
>>> static_assert(10 + mround(5) == 10, "");
>>> static_assert(11 + mround(5) == 15, "");
>>>
>>>
>>> static_assert(9 - mround(5) == 5, "");
>>> static_assert(10 - mround(5) == 10, "");
>>> static_assert(11 - mround(5) == 10, "");
>>>
>>>
>>>
>>> --
>>> 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-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> To view this discussion on the web visit
>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>

--
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/5b05d62b-b1ff-42f5-a929-e35d697c4869%40isocpp.org.

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

<div dir=3D"ltr">How about this alternative?<div><br></div><div><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><div =
class=3D"subprettyprint"><font color=3D"#660066">#include &lt;type_traits&g=
t;</font></div><div class=3D"subprettyprint"><font color=3D"#660066"><br></=
font></div><div class=3D"subprettyprint"><font color=3D"#660066">template &=
lt;typename I&gt;</font></div><div class=3D"subprettyprint"><font color=3D"=
#660066">struct mround_type</font></div><div class=3D"subprettyprint"><font=
 color=3D"#660066">=C2=A0 {</font></div><div class=3D"subprettyprint"><font=
 color=3D"#660066">=C2=A0 =C2=A0 static_assert(</font></div><div class=3D"s=
ubprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 std::is_integra=
l&lt;I&gt;::value, &quot;mround_type requires integral type&quot;);</font><=
/div><div class=3D"subprettyprint"><font color=3D"#660066"><br></font></div=
><div class=3D"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 const =
I value;</font></div><div class=3D"subprettyprint"><font color=3D"#660066">=
<br></font></div><div class=3D"subprettyprint"><font color=3D"#660066">=C2=
=A0 =C2=A0 constexpr explicit mround_type(I v) : value(v) { }</font></div><=
div class=3D"subprettyprint"><font color=3D"#660066"><br></font></div><div =
class=3D"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 // Rounded-u=
p integral division.</font></div><div class=3D"subprettyprint"><font color=
=3D"#660066">=C2=A0 =C2=A0 constexpr I div(I factor)</font></div><div class=
=3D"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 {</font></=
div><div class=3D"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 return((value + factor - 1) / factor);</font></div><div class=3D=
"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 }</font></div=
><div class=3D"subprettyprint"><font color=3D"#660066"><br></font></div><di=
v class=3D"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 // Round u=
p integer to multiple.</font></div><div class=3D"subprettyprint"><font colo=
r=3D"#660066">=C2=A0 =C2=A0 constexpr I up(I factor)</font></div><div class=
=3D"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 {</font></=
div><div class=3D"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 return(div(factor) * factor);</font></div><div class=3D"subprett=
yprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 }</font></div><div cla=
ss=3D"subprettyprint"><font color=3D"#660066"><br></font></div><div class=
=3D"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 // Round down int=
eger to multiple.</font></div><div class=3D"subprettyprint"><font color=3D"=
#660066">=C2=A0 =C2=A0 constexpr I down(I factor)</font></div><div class=3D=
"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 {</font></div=
><div class=3D"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 return(value - (value % factor));</font></div><div class=3D"subpret=
typrint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 }</font></div><div cl=
ass=3D"subprettyprint"><font color=3D"#660066">=C2=A0 };</font></div><div c=
lass=3D"subprettyprint"><font color=3D"#660066"><br></font></div><div class=
=3D"subprettyprint"><font color=3D"#660066">template &lt;typename I&gt;</fo=
nt></div><div class=3D"subprettyprint"><font color=3D"#660066">constexpr au=
to mround(I i)</font></div><div class=3D"subprettyprint"><font color=3D"#66=
0066">=C2=A0 {</font></div><div class=3D"subprettyprint"><font color=3D"#66=
0066">=C2=A0 =C2=A0 static_assert(</font></div><div class=3D"subprettyprint=
"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 std::is_integral&lt;I&gt;::v=
alue,</font></div><div class=3D"subprettyprint"><font color=3D"#660066">=C2=
=A0 =C2=A0 =C2=A0 &quot;mround() parameter must be of integral type&quot;);=
</font></div><div class=3D"subprettyprint"><font color=3D"#660066"><br></fo=
nt></div><div class=3D"subprettyprint"><font color=3D"#660066">=C2=A0 =C2=
=A0 return(mround_type&lt;I&gt;(i));</font></div><div class=3D"subprettypri=
nt"><font color=3D"#660066">=C2=A0 }</font></div><div class=3D"subprettypri=
nt"><font color=3D"#660066"><br></font></div><div class=3D"subprettyprint">=
<font color=3D"#660066">static_assert(mround(9).div(5) =3D=3D 2, &quot;&quo=
t;);</font></div><div class=3D"subprettyprint"><font color=3D"#660066">stat=
ic_assert(mround(10).div(5) =3D=3D 2, &quot;&quot;);</font></div><div class=
=3D"subprettyprint"><font color=3D"#660066">static_assert(mround(11).div(5)=
 =3D=3D 3, &quot;&quot;);</font></div><div class=3D"subprettyprint"><font c=
olor=3D"#660066"><br></font></div><div class=3D"subprettyprint"><font color=
=3D"#660066">static_assert(mround(9).up(5) =3D=3D 10, &quot;&quot;);</font>=
</div><div class=3D"subprettyprint"><font color=3D"#660066">static_assert(m=
round(10).up(5) =3D=3D 10, &quot;&quot;);</font></div><div class=3D"subpret=
typrint"><font color=3D"#660066">static_assert(mround(11).up(5) =3D=3D 15, =
&quot;&quot;);</font></div><div class=3D"subprettyprint"><font color=3D"#66=
0066"><br></font></div><div class=3D"subprettyprint"><font color=3D"#660066=
">static_assert(mround(9).down(5) =3D=3D 5, &quot;&quot;);</font></div><div=
 class=3D"subprettyprint"><font color=3D"#660066">static_assert(mround(10).=
down(5) =3D=3D 10, &quot;&quot;);</font></div><div class=3D"subprettyprint"=
><font color=3D"#660066">static_assert(mround(11).down(5) =3D=3D 10, &quot;=
&quot;);</font></div><div><br></div></div></code></div><br><br><br>On Frida=
y, December 9, 2016 at 11:30:40 AM UTC-5, Walt Karas wrote:<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">I take your point, it has val=
idity. =C2=A0But round_up_to_multiple(Integral, Integral) has issues for pe=
ople like me who don&#39;t have good memories. =C2=A0Specifically, having t=
wo parameters of the same type (that are not commutative). =C2=A0I would li=
kely be constantly looking up the right parameter order. =C2=A0And if I ddi=
n&#39;t look it up and got it wrong, that would be a run-time bug, potentia=
lly one that was very hard to find.<br><br>On Friday, December 9, 2016 at 4=
:21:28 AM UTC-5, Dawid Pilarski wrote:<blockquote class=3D"gmail_quote" sty=
le=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1e=
x"><div dir=3D"ltr"><code>I do not quite like the idea of operator + and op=
erator -. It&#39;s kind of misleading, that operator + and - has so strange=
 meaning. Why not doing just simple function round_up_to_multiple, which wo=
uld have cleaner interface?</code><code><span style=3D"color:rgb(0,0,0)"><b=
r><br></span></code></div><div><br><div class=3D"gmail_quote">2016-12-08 19=
:39 GMT+01:00 &#39;Walt Karas&#39; via ISO C++ Standard - Future Proposals =
<span dir=3D"ltr">&lt;<a rel=3D"nofollow">std-pr...@isocpp.org</a>&gt;</spa=
n>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-=
left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div style=3D"backgr=
ound-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:soli=
d;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#8=
00">#include</span><span style=3D"color:#000"> </span><span style=3D"color:=
#080">&lt;type_traits&gt;</span><span style=3D"color:#000"><br><br><br></sp=
an><span style=3D"color:#008">template</span><span style=3D"color:#000"> </=
span><span style=3D"color:#660">&lt;</span><span style=3D"color:#008">typen=
ame</span><span style=3D"color:#000"> I</span><span style=3D"color:#660">&g=
t;</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">s=
truct</span><span style=3D"color:#000"> mround_type<br>=C2=A0 </span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <=
/span><span style=3D"color:#008">static_assert</span><span style=3D"color:#=
660">(</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 std</span>=
<span style=3D"color:#660">::</span><span style=3D"color:#000">is_integral<=
/span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</s=
pan><span style=3D"color:#660">&gt;::</span><span style=3D"color:#000">valu=
e</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#080">&quot;mround_type requires integral type&quot=
;</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=
<br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">const</span><span s=
tyle=3D"color:#000"> I value</span><span style=3D"color:#660">;</span><span=
 style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"color=
:#008">constexpr</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#008">explicit</span><span style=3D"color:#000"> mround_type</span><spa=
n style=3D"color:#660">(</span><span style=3D"color:#000">I v</span><span s=
tyle=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">:</span><span style=3D"color:#000"> value</span><span style=
=3D"color:#660">(</span><span style=3D"color:#000">v</span><span style=3D"c=
olor:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:=
#660">{</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
>}</span><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:=
#660">};</span><span style=3D"color:#000"><br><br><br></span><span style=3D=
"color:#008">template</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><span =
style=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><span s=
tyle=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">auto</span><sp=
an style=3D"color:#000"> mround</span><span style=3D"color:#660">(</span><s=
pan style=3D"color:#000">I i</span><span style=3D"color:#660">)</span><span=
 style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</span>=
<span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#0=
08">static_assert</span><span style=3D"color:#660">(</span><span style=3D"c=
olor:#000"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"color:#660">::=
</span><span style=3D"color:#000">is_integral</span><span style=3D"color:#6=
60">&lt;</span><span style=3D"color:#000">I</span><span style=3D"color:#660=
">&gt;::</span><span style=3D"color:#000">value</span><span style=3D"color:=
#660">,</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 </span><s=
pan style=3D"color:#080">&quot;mround() parameter must be of integral type&=
quot;</span><span style=3D"color:#660">);</span><span style=3D"color:#000">=
<br><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#000">mround_type</sp=
an><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</span=
><span style=3D"color:#660">&gt;(</span><span style=3D"color:#000">i</span>=
<span style=3D"color:#660">));</span><span style=3D"color:#000"><br>=C2=A0 =
</span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br><b=
r><br></span><span style=3D"color:#800">// Rounded-up integral division.</s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#008">templa=
te</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;=
</span><span style=3D"color:#008">typename</span><span style=3D"color:#000"=
> I</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000">=
<br></span><span style=3D"color:#008">constexpr</span><span style=3D"color:=
#000"> I </span><span style=3D"color:#008">operator</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660">/</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">(</span><span style=3D"color:#000">=
I i</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> mr=
ound_type</span><span style=3D"color:#660">&lt;</span><span style=3D"color:=
#000">I</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#0=
00"> factor</span><span style=3D"color:#660">)</span><span style=3D"color:#=
000"><br>=C2=A0 </span><span style=3D"color:#660">{</span><span style=3D"co=
lor:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span>=
<span style=3D"color:#660">((</span><span style=3D"color:#000">i </span><sp=
an style=3D"color:#660">+</span><span style=3D"color:#000"> factor</span><s=
pan style=3D"color:#660">.</span><span style=3D"color:#000">value </span><s=
pan style=3D"color:#660">-</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#066">1</span><span style=3D"color:#660">)</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">/</span><span style=3D"c=
olor:#000"> factor</span><span style=3D"color:#660">.</span><span style=3D"=
color:#000">value</span><span style=3D"color:#660">);</span><span style=3D"=
color:#000"><br>=C2=A0 </span><span style=3D"color:#660">}</span><span styl=
e=3D"color:#000"><br><br><br></span><span style=3D"color:#800">// Round up =
integer to multiple.</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">template</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><sp=
an style=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><spa=
n style=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</spa=
n><span style=3D"color:#000"> I </span><span style=3D"color:#008">operator<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">+</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#000">I i</span><span style=3D"color:#660">,</span><span s=
tyle=3D"color:#000"> mround_type</span><span style=3D"color:#660">&lt;</spa=
n><span style=3D"color:#000">I</span><span style=3D"color:#660">&gt;</span>=
<span style=3D"color:#000"> factor</span><span style=3D"color:#660">)</span=
><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{<=
/span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"co=
lor:#008">return</span><span style=3D"color:#660">((</span><span style=3D"c=
olor:#000">i </span><span style=3D"color:#660">/</span><span style=3D"color=
:#000"> factor</span><span style=3D"color:#660">)</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">*</span><span style=3D"color:#00=
0"> factor</span><span style=3D"color:#660">.</span><span style=3D"color:#0=
00">value</span><span style=3D"color:#660">);</span><span style=3D"color:#0=
00"><br>=C2=A0 </span><span style=3D"color:#660">}</span><span style=3D"col=
or:#000"><br><br><br></span><span style=3D"color:#800">// Round down intege=
r to multiple.</span><span style=3D"color:#000"><br></span><span style=3D"c=
olor:#008">template</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">&lt;</span><span style=3D"color:#008">typename</span><span sty=
le=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><span styl=
e=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</span><spa=
n style=3D"color:#000"> I </span><span style=3D"color:#008">operator</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#660">-</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span styl=
e=3D"color:#000">I i</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> mround_type</span><span style=3D"color:#660">&lt;</span><s=
pan style=3D"color:#000">I</span><span style=3D"color:#660">&gt;</span><spa=
n style=3D"color:#000"> factor</span><span style=3D"color:#660">)</span><sp=
an style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</spa=
n><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:=
#008">return</span><span style=3D"color:#660">(</span><span style=3D"color:=
#000">i </span><span style=3D"color:#660">-</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">(</span><span style=3D"color:#000">i <=
/span><span style=3D"color:#660">%</span><span style=3D"color:#000"> factor=
</span><span style=3D"color:#660">.</span><span style=3D"color:#000">value<=
/span><span style=3D"color:#660">));</span><span style=3D"color:#000"><br>=
=C2=A0 </span><span style=3D"color:#660">}</span><span style=3D"color:#000"=
><br><br><br></span><span style=3D"color:#008">static_assert</span><span st=
yle=3D"color:#660">(</span><span style=3D"color:#066">9</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">/</span><span style=3D"c=
olor:#000"> mround</span><span style=3D"color:#660">(</span><span style=3D"=
color:#066">5</span><span style=3D"color:#660">)</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">=3D=3D</span><span style=3D"color=
:#000"> </span><span style=3D"color:#066">2</span><span style=3D"color:#660=
">,</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&qu=
ot;&quot;</span><span style=3D"color:#660">);</span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#008">static_assert</span><span style=
=3D"color:#660">(</span><span style=3D"color:#066">10</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660">/</span><span style=3D"color=
:#000"> mround</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#066">5</span><span style=3D"color:#660">)</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#066">2</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&=
quot;</span><span style=3D"color:#660">);</span><span style=3D"color:#000">=
<br></span><span style=3D"color:#008">static_assert</span><span style=3D"co=
lor:#660">(</span><span style=3D"color:#066">11</span><span style=3D"color:=
#000"> </span><span style=3D"color:#660">/</span><span style=3D"color:#000"=
> mround</span><span style=3D"color:#660">(</span><span style=3D"color:#066=
">5</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> </=
span><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </=
span><span style=3D"color:#066">3</span><span style=3D"color:#660">,</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;<=
/span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br><b=
r><br></span><span style=3D"color:#008">static_assert</span><span style=3D"=
color:#660">(</span><span style=3D"color:#066">9</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">+</span><span style=3D"color:#000=
"> mround</span><span style=3D"color:#660">(</span><span style=3D"color:#06=
6">5</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#066">10</span><span style=3D"color:#660">,</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot=
;</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=
</span><span style=3D"color:#008">static_assert</span><span style=3D"color:=
#660">(</span><span style=3D"color:#066">10</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">+</span><span style=3D"color:#000"> mr=
ound</span><span style=3D"color:#660">(</span><span style=3D"color:#066">5<=
/span><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span=
><span style=3D"color:#066">10</span><span style=3D"color:#660">,</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</sp=
an><span style=3D"color:#660">);</span><span style=3D"color:#000"><br></spa=
n><span style=3D"color:#008">static_assert</span><span style=3D"color:#660"=
>(</span><span style=3D"color:#066">11</span><span style=3D"color:#000"> </=
span><span style=3D"color:#660">+</span><span style=3D"color:#000"> mround<=
/span><span style=3D"color:#660">(</span><span style=3D"color:#066">5</span=
><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#066">15</span><span style=3D"color:#660">,</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><s=
pan style=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br></=
span><span style=3D"color:#008">static_assert</span><span style=3D"color:#6=
60">(</span><span style=3D"color:#066">9</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">-</span><span style=3D"color:#000"> mroun=
d</span><span style=3D"color:#660">(</span><span style=3D"color:#066">5</sp=
an><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#066">5</span><span style=3D"color:#660">,</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><=
span style=3D"color:#660">);</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</=
span><span style=3D"color:#066">10</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">-</span><span style=3D"color:#000"> mround</spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#066">5</span><sp=
an style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#066">10</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span=
 style=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span =
style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</span=
><span style=3D"color:#066">11</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">-</span><span style=3D"color:#000"> mround</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#066">5</span><span s=
tyle=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=
=3D"color:#066">10</span><span style=3D"color:#660">,</span><span style=3D"=
color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span sty=
le=3D"color:#660">);</span><span><font color=3D"#888888"><span style=3D"col=
or:#000"><br></span><span style=3D"color:#000"><br></span></font></span></d=
iv></code></div><span><font color=3D"#888888"><div><br><br></div></font></s=
pan></div><span><font color=3D"#888888">

<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 rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</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/1af197bf-4e85-4e4b-9486-dd7ca150c139%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/1af197bf-4e85-4e4b-<wbr>9486-=
dd7ca150c139%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br></div>
</blockquote></div></blockquote></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/5b05d62b-b1ff-42f5-a929-e35d697c4869%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869=
%40isocpp.org</a>.<br />

------=_Part_843_1774367914.1481406054162--

------=_Part_842_339972420.1481406054161--

.


Author: Dawid Pilarski <dawidpicpp@gmail.com>
Date: Mon, 12 Dec 2016 09:51:05 +0100
Raw View
--001a1147e0724a612b0543723475
Content-Type: text/plain; charset=UTF-8

How about interface like this:

Integral round_up_to_multiple(Value i, Factor factor);

With both Value and Factor having explicit constructors.
which should be called like this:
round_up_to_multiple(Value(x), Factor(y));

In fact there is no need here to introduce mround type. But I do not say
it's bad here, although Value and Factor is IMO more expressive.
It's still just an idea.

On the other hand, It would be strange also to introduce double interface.
First for / and * operators with just mround type and add and subtract with
functions. It's inconsistent IMO, however I myself gave this suggestion. I
think the API should be considered harder.

2016-12-10 22:40 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future
Proposals <std-proposals@isocpp.org>:

> How about this alternative?
>
> #include <type_traits>
>
> template <typename I>
> struct mround_type
>   {
>     static_assert(
>       std::is_integral<I>::value, "mround_type requires integral type");
>
>     const I value;
>
>     constexpr explicit mround_type(I v) : value(v) { }
>
>     // Rounded-up integral division.
>     constexpr I div(I factor)
>       {
>         return((value + factor - 1) / factor);
>       }
>
>     // Round up integer to multiple.
>     constexpr I up(I factor)
>       {
>         return(div(factor) * factor);
>       }
>
>     // Round down integer to multiple.
>     constexpr I down(I factor)
>       {
>         return(value - (value % factor));
>       }
>   };
>
> template <typename I>
> constexpr auto mround(I i)
>   {
>     static_assert(
>       std::is_integral<I>::value,
>       "mround() parameter must be of integral type");
>
>     return(mround_type<I>(i));
>   }
>
> static_assert(mround(9).div(5) == 2, "");
> static_assert(mround(10).div(5) == 2, "");
> static_assert(mround(11).div(5) == 3, "");
>
> static_assert(mround(9).up(5) == 10, "");
> static_assert(mround(10).up(5) == 10, "");
> static_assert(mround(11).up(5) == 15, "");
>
> static_assert(mround(9).down(5) == 5, "");
> static_assert(mround(10).down(5) == 10, "");
> static_assert(mround(11).down(5) == 10, "");
>
>
>
>
> On Friday, December 9, 2016 at 11:30:40 AM UTC-5, Walt Karas wrote:
>
>> I take your point, it has validity.  But round_up_to_multiple(Integral,
>> Integral) has issues for people like me who don't have good memories.
>> Specifically, having two parameters of the same type (that are not
>> commutative).  I would likely be constantly looking up the right parameter
>> order.  And if I ddin't look it up and got it wrong, that would be a
>> run-time bug, potentially one that was very hard to find.
>>
>> On Friday, December 9, 2016 at 4:21:28 AM UTC-5, Dawid Pilarski wrote:
>>>
>>> I do not quite like the idea of operator + and operator -. It's kind of
>>> misleading, that operator + and - has so strange meaning. Why not doing
>>> just simple function round_up_to_multiple, which would have cleaner
>>> interface?
>>>
>>>
>>> 2016-12-08 19:39 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future
>>> Proposals <std-pr...@isocpp.org>:
>>>
>>>> #include <type_traits>
>>>>
>>>>
>>>> template <typename I>
>>>> struct mround_type
>>>>   {
>>>>     static_assert(
>>>>       std::is_integral<I>::value, "mround_type requires integral type"
>>>> );
>>>>
>>>>
>>>>     const I value;
>>>>
>>>>
>>>>     constexpr explicit mround_type(I v) : value(v) { }
>>>>   };
>>>>
>>>>
>>>> template <typename I>
>>>> constexpr auto mround(I i)
>>>>   {
>>>>     static_assert(
>>>>       std::is_integral<I>::value,
>>>>       "mround() parameter must be of integral type");
>>>>
>>>>
>>>>     return(mround_type<I>(i));
>>>>   }
>>>>
>>>>
>>>> // Rounded-up integral division.
>>>> template <typename I>
>>>> constexpr I operator / (I i, mround_type<I> factor)
>>>>   {
>>>>     return((i + factor.value - 1) / factor.value);
>>>>   }
>>>>
>>>>
>>>> // Round up integer to multiple.
>>>> template <typename I>
>>>> constexpr I operator + (I i, mround_type<I> factor)
>>>>   {
>>>>     return((i / factor) * factor.value);
>>>>   }
>>>>
>>>>
>>>> // Round down integer to multiple.
>>>> template <typename I>
>>>> constexpr I operator - (I i, mround_type<I> factor)
>>>>   {
>>>>     return(i - (i % factor.value));
>>>>   }
>>>>
>>>>
>>>> static_assert(9 / mround(5) == 2, "");
>>>> static_assert(10 / mround(5) == 2, "");
>>>> static_assert(11 / mround(5) == 3, "");
>>>>
>>>>
>>>> static_assert(9 + mround(5) == 10, "");
>>>> static_assert(10 + mround(5) == 10, "");
>>>> static_assert(11 + mround(5) == 15, "");
>>>>
>>>>
>>>> static_assert(9 - mround(5) == 5, "");
>>>> static_assert(10 - mround(5) == 10, "");
>>>> static_assert(11 - mround(5) == 10, "");
>>>>
>>>>
>>>>
>>>> --
>>>> 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-proposal...@isocpp.org.
>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>> To view this discussion on the web visit https://groups.google.com/a/is
>>>> ocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-
>>>> dd7ca150c139%40isocpp.org
>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>
>>> --
> 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/5b05d62b-b1ff-42f5-
> a929-e35d697c4869%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
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/CAOkZZiGu%3D0npBDvz4yJmhrYa71_eatvzt8EnVWMFebT6sNJ20A%40mail.gmail.com.

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

<div dir=3D"ltr"><div><div><div>How about interface like this:<br><br>Integ=
ral round_up_to_multiple(Value i, Factor factor); <br><br></div><div>With b=
oth Value and Factor having explicit constructors.<br></div>which should be=
 called like this:<br>round_up_to_multiple(Value(x), Factor(y));<br><br></d=
iv>In fact there is no need here to introduce mround type. But I do not say=
 it&#39;s bad here, although Value and Factor is IMO more expressive.<br></=
div><div>It&#39;s still just an idea.<br><br></div><div>On the other hand, =
It would be strange also to introduce double interface. <br></div><div>Firs=
t for / and * operators with just mround type and add and subtract with fun=
ctions. It&#39;s inconsistent IMO, however I myself gave this suggestion. I=
 think the API should be considered harder.<br></div></div><div class=3D"gm=
ail_extra"><br><div class=3D"gmail_quote">2016-12-10 22:40 GMT+01:00 &#39;W=
alt Karas&#39; via ISO C++ Standard - Future Proposals <span dir=3D"ltr">&l=
t;<a href=3D"mailto:std-proposals@isocpp.org" target=3D"_blank">std-proposa=
ls@isocpp.org</a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D=
"ltr">How about this alternative?<div><br></div><div><div class=3D"m_-37073=
51283503015102prettyprint" style=3D"background-color:rgb(250,250,250);borde=
r-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:brea=
k-word"><code class=3D"m_-3707351283503015102prettyprint"><div class=3D"m_-=
3707351283503015102subprettyprint"><span class=3D""><div class=3D"m_-370735=
1283503015102subprettyprint"><font color=3D"#660066">#include &lt;type_trai=
ts&gt;</font></div><div class=3D"m_-3707351283503015102subprettyprint"><fon=
t color=3D"#660066"><br></font></div><div class=3D"m_-3707351283503015102su=
bprettyprint"><font color=3D"#660066">template &lt;typename I&gt;</font></d=
iv><div class=3D"m_-3707351283503015102subprettyprint"><font color=3D"#6600=
66">struct mround_type</font></div><div class=3D"m_-3707351283503015102subp=
rettyprint"><font color=3D"#660066">=C2=A0 {</font></div><div class=3D"m_-3=
707351283503015102subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 sta=
tic_assert(</font></div><div class=3D"m_-3707351283503015102subprettyprint"=
><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 std::is_integral&lt;I&gt;::va=
lue, &quot;mround_type requires integral type&quot;);</font></div><div clas=
s=3D"m_-3707351283503015102subprettyprint"><font color=3D"#660066"><br></fo=
nt></div><div class=3D"m_-3707351283503015102subprettyprint"><font color=3D=
"#660066">=C2=A0 =C2=A0 const I value;</font></div><div class=3D"m_-3707351=
283503015102subprettyprint"><font color=3D"#660066"><br></font></div><div c=
lass=3D"m_-3707351283503015102subprettyprint"><font color=3D"#660066">=C2=
=A0 =C2=A0 constexpr explicit mround_type(I v) : value(v) { }</font></div><=
div class=3D"m_-3707351283503015102subprettyprint"><font color=3D"#660066">=
<br></font></div></span><div class=3D"m_-3707351283503015102subprettyprint"=
><font color=3D"#660066">=C2=A0 =C2=A0 // Rounded-up integral division.</fo=
nt></div><div class=3D"m_-3707351283503015102subprettyprint"><font color=3D=
"#660066">=C2=A0 =C2=A0 constexpr I div(I factor)</font></div><div class=3D=
"m_-3707351283503015102subprettyprint"><font color=3D"#660066">=C2=A0 =C2=
=A0 =C2=A0 {</font></div><div class=3D"m_-3707351283503015102subprettyprint=
"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return((value + facto=
r - 1) / factor);</font></div><span class=3D""><div class=3D"m_-37073512835=
03015102subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 }</fon=
t></div><div class=3D"m_-3707351283503015102subprettyprint"><font color=3D"=
#660066"><br></font></div><div class=3D"m_-3707351283503015102subprettyprin=
t"><font color=3D"#660066">=C2=A0 =C2=A0 // Round up integer to multiple.</=
font></div></span><div class=3D"m_-3707351283503015102subprettyprint"><font=
 color=3D"#660066">=C2=A0 =C2=A0 constexpr I up(I factor)</font></div><div =
class=3D"m_-3707351283503015102subprettyprint"><font color=3D"#660066">=C2=
=A0 =C2=A0 =C2=A0 {</font></div><div class=3D"m_-3707351283503015102subpret=
typrint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return(div(fac=
tor) * factor);</font></div><span class=3D""><div class=3D"m_-3707351283503=
015102subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 }</font>=
</div><div class=3D"m_-3707351283503015102subprettyprint"><font color=3D"#6=
60066"><br></font></div><div class=3D"m_-3707351283503015102subprettyprint"=
><font color=3D"#660066">=C2=A0 =C2=A0 // Round down integer to multiple.</=
font></div></span><div class=3D"m_-3707351283503015102subprettyprint"><font=
 color=3D"#660066">=C2=A0 =C2=A0 constexpr I down(I factor)</font></div><di=
v class=3D"m_-3707351283503015102subprettyprint"><font color=3D"#660066">=
=C2=A0 =C2=A0 =C2=A0 {</font></div><div class=3D"m_-3707351283503015102subp=
rettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return(valu=
e - (value % factor));</font></div><span class=3D""><div class=3D"m_-370735=
1283503015102subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 }=
</font></div><div class=3D"m_-3707351283503015102subprettyprint"><font colo=
r=3D"#660066">=C2=A0 };</font></div><div class=3D"m_-3707351283503015102sub=
prettyprint"><font color=3D"#660066"><br></font></div><div class=3D"m_-3707=
351283503015102subprettyprint"><font color=3D"#660066">template &lt;typenam=
e I&gt;</font></div><div class=3D"m_-3707351283503015102subprettyprint"><fo=
nt color=3D"#660066">constexpr auto mround(I i)</font></div><div class=3D"m=
_-3707351283503015102subprettyprint"><font color=3D"#660066">=C2=A0 {</font=
></div><div class=3D"m_-3707351283503015102subprettyprint"><font color=3D"#=
660066">=C2=A0 =C2=A0 static_assert(</font></div><div class=3D"m_-370735128=
3503015102subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 std:=
:is_integral&lt;I&gt;::value,</font></div><div class=3D"m_-3707351283503015=
102subprettyprint"><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 &quot;mroun=
d() parameter must be of integral type&quot;);</font></div><div class=3D"m_=
-3707351283503015102subprettyprint"><font color=3D"#660066"><br></font></di=
v><div class=3D"m_-3707351283503015102subprettyprint"><font color=3D"#66006=
6">=C2=A0 =C2=A0 return(mround_type&lt;I&gt;(i));</font></div><div class=3D=
"m_-3707351283503015102subprettyprint"><font color=3D"#660066">=C2=A0 }</fo=
nt></div><div class=3D"m_-3707351283503015102subprettyprint"><font color=3D=
"#660066"><br></font></div></span><div class=3D"m_-3707351283503015102subpr=
ettyprint"><font color=3D"#660066">static_assert(mround(9).div(5) =3D=3D 2,=
 &quot;&quot;);</font></div><div class=3D"m_-3707351283503015102subprettypr=
int"><font color=3D"#660066">static_assert(mround(10).div(<wbr>5) =3D=3D 2,=
 &quot;&quot;);</font></div><div class=3D"m_-3707351283503015102subprettypr=
int"><font color=3D"#660066">static_assert(mround(11).div(<wbr>5) =3D=3D 3,=
 &quot;&quot;);</font></div><div class=3D"m_-3707351283503015102subprettypr=
int"><font color=3D"#660066"><br></font></div><div class=3D"m_-370735128350=
3015102subprettyprint"><font color=3D"#660066">static_assert(mround(9).up(5=
) =3D=3D 10, &quot;&quot;);</font></div><div class=3D"m_-370735128350301510=
2subprettyprint"><font color=3D"#660066">static_assert(mround(10).up(5) =3D=
=3D 10, &quot;&quot;);</font></div><div class=3D"m_-3707351283503015102subp=
rettyprint"><font color=3D"#660066">static_assert(mround(11).up(5) =3D=3D 1=
5, &quot;&quot;);</font></div><div class=3D"m_-3707351283503015102subpretty=
print"><font color=3D"#660066"><br></font></div><div class=3D"m_-3707351283=
503015102subprettyprint"><font color=3D"#660066">static_assert(mround(9).do=
wn(<wbr>5) =3D=3D 5, &quot;&quot;);</font></div><div class=3D"m_-3707351283=
503015102subprettyprint"><font color=3D"#660066">static_assert(mround(10).d=
own(<wbr>5) =3D=3D 10, &quot;&quot;);</font></div><div class=3D"m_-37073512=
83503015102subprettyprint"><font color=3D"#660066">static_assert(mround(11)=
..down(<wbr>5) =3D=3D 10, &quot;&quot;);</font></div><div><br></div></div></=
code></div><span class=3D""><br><br><br>On Friday, December 9, 2016 at 11:3=
0:40 AM UTC-5, Walt Karas wrote:</span><div><div class=3D"h5"><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div dir=3D"ltr">I take your point, it has valid=
ity.=C2=A0 But round_up_to_multiple(Integral, Integral) has issues for peop=
le like me who don&#39;t have good memories.=C2=A0 Specifically, having two=
 parameters of the same type (that are not commutative).=C2=A0 I would like=
ly be constantly looking up the right parameter order.=C2=A0 And if I ddin&=
#39;t look it up and got it wrong, that would be a run-time bug, potentiall=
y one that was very hard to find.<br><br>On Friday, December 9, 2016 at 4:2=
1:28 AM UTC-5, Dawid Pilarski 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"><code>I do not quite like the idea of operator + and oper=
ator -. It&#39;s kind of misleading, that operator + and - has so strange m=
eaning. Why not doing just simple function round_up_to_multiple, which woul=
d have cleaner interface?</code><code><span style=3D"color:rgb(0,0,0)"><br>=
<br></span></code></div><div><br><div class=3D"gmail_quote">2016-12-08 19:3=
9 GMT+01:00 &#39;Walt Karas&#39; via ISO C++ Standard - Future Proposals <s=
pan dir=3D"ltr">&lt;<a rel=3D"nofollow">std-pr...@isocpp.org</a>&gt;</span>=
:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div style=3D"backgrou=
nd-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;=
border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#800=
">#include</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
80">&lt;type_traits&gt;</span><span style=3D"color:#000"><br><br><br></span=
><span style=3D"color:#008">template</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">&lt;</span><span style=3D"color:#008">typenam=
e</span><span style=3D"color:#000"> I</span><span style=3D"color:#660">&gt;=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">str=
uct</span><span style=3D"color:#000"> mround_type<br>=C2=A0 </span><span st=
yle=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </s=
pan><span style=3D"color:#008">static_assert</span><span style=3D"color:#66=
0">(</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 std</span><s=
pan style=3D"color:#660">::</span><span style=3D"color:#000">is_integral</s=
pan><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</spa=
n><span style=3D"color:#660">&gt;::</span><span style=3D"color:#000">value<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span=
><span style=3D"color:#080">&quot;mround_type requires integral type&quot;<=
/span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br><b=
r><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">const</span><span sty=
le=3D"color:#000"> I value</span><span style=3D"color:#660">;</span><span s=
tyle=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#=
008">constexpr</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#008">explicit</span><span style=3D"color:#000"> mround_type</span><span =
style=3D"color:#660">(</span><span style=3D"color:#000">I v</span><span sty=
le=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">:</span><span style=3D"color:#000"> value</span><span style=3D=
"color:#660">(</span><span style=3D"color:#000">v</span><span style=3D"colo=
r:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">{</span><span style=3D"color:#000"> </span><span style=3D"color:#660">}<=
/span><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#66=
0">};</span><span style=3D"color:#000"><br><br><br></span><span style=3D"co=
lor:#008">template</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">&lt;</span><span style=3D"color:#008">typename</span><span styl=
e=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#008">auto</span><span s=
tyle=3D"color:#000"> mround</span><span style=3D"color:#660">(</span><span =
style=3D"color:#000">I i</span><span style=3D"color:#660">)</span><span sty=
le=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</span><spa=
n style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">=
static_assert</span><span style=3D"color:#660">(</span><span style=3D"color=
:#000"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</sp=
an><span style=3D"color:#000">is_integral</span><span style=3D"color:#660">=
&lt;</span><span style=3D"color:#000">I</span><span style=3D"color:#660">&g=
t;::</span><span style=3D"color:#000">value</span><span style=3D"color:#660=
">,</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 </span><span =
style=3D"color:#080">&quot;mround() parameter must be of integral type&quot=
;</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=
<br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span =
style=3D"color:#660">(</span><span style=3D"color:#000">mround_type</span><=
span style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</span><sp=
an style=3D"color:#660">&gt;(</span><span style=3D"color:#000">i</span><spa=
n style=3D"color:#660">));</span><span style=3D"color:#000"><br>=C2=A0 </sp=
an><span style=3D"color:#660">}</span><span style=3D"color:#000"><br><br><b=
r></span><span style=3D"color:#800">// Rounded-up integral division.</span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#008">template</=
span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</sp=
an><span style=3D"color:#008">typename</span><span style=3D"color:#000"> I<=
/span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br>=
</span><span style=3D"color:#008">constexpr</span><span style=3D"color:#000=
"> I </span><span style=3D"color:#008">operator</span><span style=3D"color:=
#000"> </span><span style=3D"color:#660">/</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">(</span><span style=3D"color:#000">I i<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> mround=
_type</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000=
">I</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000">=
 factor</span><span style=3D"color:#660">)</span><span style=3D"color:#000"=
><br>=C2=A0 </span><span style=3D"color:#660">{</span><span style=3D"color:=
#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><spa=
n style=3D"color:#660">((</span><span style=3D"color:#000">i </span><span s=
tyle=3D"color:#660">+</span><span style=3D"color:#000"> factor</span><span =
style=3D"color:#660">.</span><span style=3D"color:#000">value </span><span =
style=3D"color:#660">-</span><span style=3D"color:#000"> </span><span style=
=3D"color:#066">1</span><span style=3D"color:#660">)</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">/</span><span style=3D"color:=
#000"> factor</span><span style=3D"color:#660">.</span><span style=3D"color=
:#000">value</span><span style=3D"color:#660">);</span><span style=3D"color=
:#000"><br>=C2=A0 </span><span style=3D"color:#660">}</span><span style=3D"=
color:#000"><br><br><br></span><span style=3D"color:#800">// Round up integ=
er to multiple.</span><span style=3D"color:#000"><br></span><span style=3D"=
color:#008">template</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><span =
style=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><span s=
tyle=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</span><=
span style=3D"color:#000"> I </span><span style=3D"color:#008">operator</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">+</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span s=
tyle=3D"color:#000">I i</span><span style=3D"color:#660">,</span><span styl=
e=3D"color:#000"> mround_type</span><span style=3D"color:#660">&lt;</span><=
span style=3D"color:#000">I</span><span style=3D"color:#660">&gt;</span><sp=
an style=3D"color:#000"> factor</span><span style=3D"color:#660">)</span><s=
pan style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color=
:#008">return</span><span style=3D"color:#660">((</span><span style=3D"colo=
r:#000">i </span><span style=3D"color:#660">/</span><span style=3D"color:#0=
00"> factor</span><span style=3D"color:#660">)</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">*</span><span style=3D"color:#000">=
 factor</span><span style=3D"color:#660">.</span><span style=3D"color:#000"=
>value</span><span style=3D"color:#660">);</span><span style=3D"color:#000"=
><br>=C2=A0 </span><span style=3D"color:#660">}</span><span style=3D"color:=
#000"><br><br><br></span><span style=3D"color:#800">// Round down integer t=
o multiple.</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#008">template</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#660">&lt;</span><span style=3D"color:#008">typename</span><span style=
=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</span><span=
 style=3D"color:#000"> I </span><span style=3D"color:#008">operator</span><=
span style=3D"color:#000"> </span><span style=3D"color:#660">-</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">I i</span><span style=3D"color:#660">,</span><span style=3D=
"color:#000"> mround_type</span><span style=3D"color:#660">&lt;</span><span=
 style=3D"color:#000">I</span><span style=3D"color:#660">&gt;</span><span s=
tyle=3D"color:#000"> factor</span><span style=3D"color:#660">)</span><span =
style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</span><=
span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#00=
8">return</span><span style=3D"color:#660">(</span><span style=3D"color:#00=
0">i </span><span style=3D"color:#660">-</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">(</span><span style=3D"color:#000">i </sp=
an><span style=3D"color:#660">%</span><span style=3D"color:#000"> factor</s=
pan><span style=3D"color:#660">.</span><span style=3D"color:#000">value</sp=
an><span style=3D"color:#660">));</span><span style=3D"color:#000"><br>=C2=
=A0 </span><span style=3D"color:#660">}</span><span style=3D"color:#000"><b=
r><br><br></span><span style=3D"color:#008">static_assert</span><span style=
=3D"color:#660">(</span><span style=3D"color:#066">9</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">/</span><span style=3D"color:=
#000"> mround</span><span style=3D"color:#660">(</span><span style=3D"color=
:#066">5</span><span style=3D"color:#660">)</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000=
"> </span><span style=3D"color:#066">2</span><span style=3D"color:#660">,</=
span><span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&q=
uot;</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><=
br></span><span style=3D"color:#008">static_assert</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#066">10</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">/</span><span style=3D"color:#000">=
 mround</span><span style=3D"color:#660">(</span><span style=3D"color:#066"=
>5</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#066">2</span><span style=3D"color:#660">,</span><=
span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</=
span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br></s=
pan><span style=3D"color:#008">static_assert</span><span style=3D"color:#66=
0">(</span><span style=3D"color:#066">11</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">/</span><span style=3D"color:#000"> mroun=
d</span><span style=3D"color:#660">(</span><span style=3D"color:#066">5</sp=
an><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#066">3</span><span style=3D"color:#660">,</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><=
span style=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br><=
/span><span style=3D"color:#008">static_assert</span><span style=3D"color:#=
660">(</span><span style=3D"color:#066">9</span><span style=3D"color:#000">=
 </span><span style=3D"color:#660">+</span><span style=3D"color:#000"> mrou=
nd</span><span style=3D"color:#660">(</span><span style=3D"color:#066">5</s=
pan><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><=
span style=3D"color:#066">10</span><span style=3D"color:#660">,</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span=
><span style=3D"color:#660">);</span><span style=3D"color:#000"><br></span>=
<span style=3D"color:#008">static_assert</span><span style=3D"color:#660">(=
</span><span style=3D"color:#066">10</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">+</span><span style=3D"color:#000"> mround</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#066">5</span><=
span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span =
style=3D"color:#066">10</span><span style=3D"color:#660">,</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><spa=
n style=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span=
 style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</spa=
n><span style=3D"color:#066">11</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">+</span><span style=3D"color:#000"> mround</span><=
span style=3D"color:#660">(</span><span style=3D"color:#066">5</span><span =
style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=
=3D"color:#066">15</span><span style=3D"color:#660">,</span><span style=3D"=
color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span sty=
le=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br></span><s=
pan style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</=
span><span style=3D"color:#066">9</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">-</span><span style=3D"color:#000"> mround</span=
><span style=3D"color:#660">(</span><span style=3D"color:#066">5</span><spa=
n style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#066">5</span><span style=3D"color:#660">,</span><span style=3D=
"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span st=
yle=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span sty=
le=3D"color:#008">static_assert</span><span style=3D"color:#660">(</span><s=
pan style=3D"color:#066">10</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">-</span><span style=3D"color:#000"> mround</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#066">5</span><span styl=
e=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"=
color:#066">10</span><span style=3D"color:#660">,</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=
=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">static_assert</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#066">11</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">-</span><span style=3D"color:#000"> mround</span><span s=
tyle=3D"color:#660">(</span><span style=3D"color:#066">5</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#066">10</span><span style=3D"color:#660">,</span><span style=3D"color=
:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=3D=
"color:#660">);</span><span><font color=3D"#888888"><span style=3D"color:#0=
00"><br></span><span style=3D"color:#000"><br></span></font></span></div></=
code></div><span><font color=3D"#888888"><div><br><br></div></font></span><=
/div><span><font color=3D"#888888">

<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 rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</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/1af197bf-4e85-4e4b-9486-dd7ca150c139%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-pr=
oposals<wbr>/1af197bf-4e85-4e4b-9486-<wbr>dd7ca150c139%40isocpp.org</a>.<br=
>
</font></span></blockquote></div><br></div>
</blockquote></div></blockquote></div></div></div></div><div><div class=3D"=
h5">

<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/5b05=
d62b-b1ff-42f5-<wbr>a929-e35d697c4869%40isocpp.org</a><wbr>.<br>
</blockquote></div><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/CAOkZZiGu%3D0npBDvz4yJmhrYa71_eatvzt8=
EnVWMFebT6sNJ20A%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOkZZiGu%3D0np=
BDvz4yJmhrYa71_eatvzt8EnVWMFebT6sNJ20A%40mail.gmail.com</a>.<br />

--001a1147e0724a612b0543723475--

.


Author: "'Walt Karas' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Mon, 12 Dec 2016 07:23:09 -0800 (PST)
Raw View
------=_Part_1253_1682199006.1481556189751
Content-Type: multipart/alternative;
 boundary="----=_Part_1254_2143755811.1481556189753"

------=_Part_1254_2143755811.1481556189753
Content-Type: text/plain; charset=UTF-8

I don't see how that would work.  Are Value and Factor concepts rather than
templates in your suggestion?  I only have a very rough idea of what's in
the Concepts TS.

On Monday, December 12, 2016 at 3:51:08 AM UTC-5, Dawid Pilarski wrote:
>
> How about interface like this:
>
> Integral round_up_to_multiple(Value i, Factor factor);
>
> With both Value and Factor having explicit constructors.
> which should be called like this:
> round_up_to_multiple(Value(x), Factor(y));
>
> In fact there is no need here to introduce mround type. But I do not say
> it's bad here, although Value and Factor is IMO more expressive.
> It's still just an idea.
>
> On the other hand, It would be strange also to introduce double interface.
> First for / and * operators with just mround type and add and subtract
> with functions. It's inconsistent IMO, however I myself gave this
> suggestion. I think the API should be considered harder.
>
> 2016-12-10 22:40 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future
> Proposals <std-pr...@isocpp.org <javascript:>>:
>
>> How about this alternative?
>>
>> #include <type_traits>
>>
>> template <typename I>
>> struct mround_type
>>   {
>>     static_assert(
>>       std::is_integral<I>::value, "mround_type requires integral type");
>>
>>     const I value;
>>
>>     constexpr explicit mround_type(I v) : value(v) { }
>>
>>     // Rounded-up integral division.
>>     constexpr I div(I factor)
>>       {
>>         return((value + factor - 1) / factor);
>>       }
>>
>>     // Round up integer to multiple.
>>     constexpr I up(I factor)
>>       {
>>         return(div(factor) * factor);
>>       }
>>
>>     // Round down integer to multiple.
>>     constexpr I down(I factor)
>>       {
>>         return(value - (value % factor));
>>       }
>>   };
>>
>> template <typename I>
>> constexpr auto mround(I i)
>>   {
>>     static_assert(
>>       std::is_integral<I>::value,
>>       "mround() parameter must be of integral type");
>>
>>     return(mround_type<I>(i));
>>   }
>>
>> static_assert(mround(9).div(5) == 2, "");
>> static_assert(mround(10).div(5) == 2, "");
>> static_assert(mround(11).div(5) == 3, "");
>>
>> static_assert(mround(9).up(5) == 10, "");
>> static_assert(mround(10).up(5) == 10, "");
>> static_assert(mround(11).up(5) == 15, "");
>>
>> static_assert(mround(9).down(5) == 5, "");
>> static_assert(mround(10).down(5) == 10, "");
>> static_assert(mround(11).down(5) == 10, "");
>>
>>
>>
>>
>> On Friday, December 9, 2016 at 11:30:40 AM UTC-5, Walt Karas wrote:
>>
>>> I take your point, it has validity.  But round_up_to_multiple(Integral,
>>> Integral) has issues for people like me who don't have good memories.
>>> Specifically, having two parameters of the same type (that are not
>>> commutative).  I would likely be constantly looking up the right parameter
>>> order.  And if I ddin't look it up and got it wrong, that would be a
>>> run-time bug, potentially one that was very hard to find.
>>>
>>> On Friday, December 9, 2016 at 4:21:28 AM UTC-5, Dawid Pilarski wrote:
>>>>
>>>> I do not quite like the idea of operator + and operator -. It's kind of
>>>> misleading, that operator + and - has so strange meaning. Why not doing
>>>> just simple function round_up_to_multiple, which would have cleaner
>>>> interface?
>>>>
>>>>
>>>> 2016-12-08 19:39 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future
>>>> Proposals <std-pr...@isocpp.org>:
>>>>
>>>>> #include <type_traits>
>>>>>
>>>>>
>>>>> template <typename I>
>>>>> struct mround_type
>>>>>   {
>>>>>     static_assert(
>>>>>       std::is_integral<I>::value, "mround_type requires integral type"
>>>>> );
>>>>>
>>>>>
>>>>>     const I value;
>>>>>
>>>>>
>>>>>     constexpr explicit mround_type(I v) : value(v) { }
>>>>>   };
>>>>>
>>>>>
>>>>> template <typename I>
>>>>> constexpr auto mround(I i)
>>>>>   {
>>>>>     static_assert(
>>>>>       std::is_integral<I>::value,
>>>>>       "mround() parameter must be of integral type");
>>>>>
>>>>>
>>>>>     return(mround_type<I>(i));
>>>>>   }
>>>>>
>>>>>
>>>>> // Rounded-up integral division.
>>>>> template <typename I>
>>>>> constexpr I operator / (I i, mround_type<I> factor)
>>>>>   {
>>>>>     return((i + factor.value - 1) / factor.value);
>>>>>   }
>>>>>
>>>>>
>>>>> // Round up integer to multiple.
>>>>> template <typename I>
>>>>> constexpr I operator + (I i, mround_type<I> factor)
>>>>>   {
>>>>>     return((i / factor) * factor.value);
>>>>>   }
>>>>>
>>>>>
>>>>> // Round down integer to multiple.
>>>>> template <typename I>
>>>>> constexpr I operator - (I i, mround_type<I> factor)
>>>>>   {
>>>>>     return(i - (i % factor.value));
>>>>>   }
>>>>>
>>>>>
>>>>> static_assert(9 / mround(5) == 2, "");
>>>>> static_assert(10 / mround(5) == 2, "");
>>>>> static_assert(11 / mround(5) == 3, "");
>>>>>
>>>>>
>>>>> static_assert(9 + mround(5) == 10, "");
>>>>> static_assert(10 + mround(5) == 10, "");
>>>>> static_assert(11 + mround(5) == 15, "");
>>>>>
>>>>>
>>>>> static_assert(9 - mround(5) == 5, "");
>>>>> static_assert(10 - mround(5) == 10, "");
>>>>> static_assert(11 - mround(5) == 10, "");
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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-proposal...@isocpp.org.
>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org
>>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>
>>>> --
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%40isocpp.org?utm_medium=email&utm_source=footer>
>> .
>>
>
>

--
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/be7fb134-efa2-4f35-aa0f-51b11efc52da%40isocpp.org.

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

<div dir=3D"ltr">I don&#39;t see how that would work. =C2=A0Are Value and F=
actor concepts rather than templates in your suggestion? =C2=A0I only have =
a very rough idea of what&#39;s in the Concepts TS.<div><br>On Monday, Dece=
mber 12, 2016 at 3:51:08 AM UTC-5, Dawid Pilarski wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div><div>How about inter=
face like this:<br><br>Integral round_up_to_multiple(Value i, Factor factor=
); <br><br></div><div>With both Value and Factor having explicit constructo=
rs.<br></div>which should be called like this:<br>round_up_to_multiple(Valu=
e(x), Factor(y));<br><br></div>In fact there is no need here to introduce m=
round type. But I do not say it&#39;s bad here, although Value and Factor i=
s IMO more expressive.<br></div><div>It&#39;s still just an idea.<br><br></=
div><div>On the other hand, It would be strange also to introduce double in=
terface. <br></div><div>First for / and * operators with just mround type a=
nd add and subtract with functions. It&#39;s inconsistent IMO, however I my=
self gave this suggestion. I think the API should be considered harder.<br>=
</div></div><div><br><div class=3D"gmail_quote">2016-12-10 22:40 GMT+01:00 =
&#39;Walt Karas&#39; via ISO C++ Standard - Future Proposals <span dir=3D"l=
tr">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
Q0DlErUbCQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-pr...@isocpp.org</a>&gt;</span>:<br><blockquote class=3D"gmail_quote=
" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><=
div dir=3D"ltr">How about this alternative?<div><br></div><div><div style=
=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-=
style:solid;border-width:1px;word-wrap:break-word"><code><div><span><div><f=
ont color=3D"#660066">#include &lt;type_traits&gt;</font></div><div><font c=
olor=3D"#660066"><br></font></div><div><font color=3D"#660066">template &lt=
;typename I&gt;</font></div><div><font color=3D"#660066">struct mround_type=
</font></div><div><font color=3D"#660066">=C2=A0 {</font></div><div><font c=
olor=3D"#660066">=C2=A0 =C2=A0 static_assert(</font></div><div><font color=
=3D"#660066">=C2=A0 =C2=A0 =C2=A0 std::is_integral&lt;I&gt;::value, &quot;m=
round_type requires integral type&quot;);</font></div><div><font color=3D"#=
660066"><br></font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 const I=
 value;</font></div><div><font color=3D"#660066"><br></font></div><div><fon=
t color=3D"#660066">=C2=A0 =C2=A0 constexpr explicit mround_type(I v) : val=
ue(v) { }</font></div><div><font color=3D"#660066"><br></font></div></span>=
<div><font color=3D"#660066">=C2=A0 =C2=A0 // Rounded-up integral division.=
</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 constexpr I div(I f=
actor)</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 {</fon=
t></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return((va=
lue + factor - 1) / factor);</font></div><span><div><font color=3D"#660066"=
>=C2=A0 =C2=A0 =C2=A0 }</font></div><div><font color=3D"#660066"><br></font=
></div><div><font color=3D"#660066">=C2=A0 =C2=A0 // Round up integer to mu=
ltiple.</font></div></span><div><font color=3D"#660066">=C2=A0 =C2=A0 const=
expr I up(I factor)</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =
=C2=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 return(div(factor) * factor);</font></div><span><div><font color=3D"#66=
0066">=C2=A0 =C2=A0 =C2=A0 }</font></div><div><font color=3D"#660066"><br><=
/font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 // Round down intege=
r to multiple.</font></div></span><div><font color=3D"#660066">=C2=A0 =C2=
=A0 constexpr I down(I factor)</font></div><div><font color=3D"#660066">=C2=
=A0 =C2=A0 =C2=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 return(value - (value % factor));</font></div><span><div><fon=
t color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 }</font></div><div><font color=3D"=
#660066">=C2=A0 };</font></div><div><font color=3D"#660066"><br></font></di=
v><div><font color=3D"#660066">template &lt;typename I&gt;</font></div><div=
><font color=3D"#660066">constexpr auto mround(I i)</font></div><div><font =
color=3D"#660066">=C2=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =
=C2=A0 static_assert(</font></div><div><font color=3D"#660066">=C2=A0 =C2=
=A0 =C2=A0 std::is_integral&lt;I&gt;::value,</font></div><div><font color=
=3D"#660066">=C2=A0 =C2=A0 =C2=A0 &quot;mround() parameter must be of integ=
ral type&quot;);</font></div><div><font color=3D"#660066"><br></font></div>=
<div><font color=3D"#660066">=C2=A0 =C2=A0 return(mround_type&lt;I&gt;(i));=
</font></div><div><font color=3D"#660066">=C2=A0 }</font></div><div><font c=
olor=3D"#660066"><br></font></div></span><div><font color=3D"#660066">stati=
c_assert(mround(9).div(5) =3D=3D 2, &quot;&quot;);</font></div><div><font c=
olor=3D"#660066">static_assert(mround(10).div(<wbr>5) =3D=3D 2, &quot;&quot=
;);</font></div><div><font color=3D"#660066">static_assert(mround(11).div(<=
wbr>5) =3D=3D 3, &quot;&quot;);</font></div><div><font color=3D"#660066"><b=
r></font></div><div><font color=3D"#660066">static_assert(mround(9).up(5) =
=3D=3D 10, &quot;&quot;);</font></div><div><font color=3D"#660066">static_a=
ssert(mround(10).up(5) =3D=3D 10, &quot;&quot;);</font></div><div><font col=
or=3D"#660066">static_assert(mround(11).up(5) =3D=3D 15, &quot;&quot;);</fo=
nt></div><div><font color=3D"#660066"><br></font></div><div><font color=3D"=
#660066">static_assert(mround(9).down(<wbr>5) =3D=3D 5, &quot;&quot;);</fon=
t></div><div><font color=3D"#660066">static_assert(mround(10).down(<wbr>5) =
=3D=3D 10, &quot;&quot;);</font></div><div><font color=3D"#660066">static_a=
ssert(mround(11).down(<wbr>5) =3D=3D 10, &quot;&quot;);</font></div><div><b=
r></div></div></code></div><span><br><br><br>On Friday, December 9, 2016 at=
 11:30:40 AM UTC-5, Walt Karas wrote:</span><div><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">I take your point, it has validity.=C2=
=A0 But round_up_to_multiple(Integral, Integral) has issues for people like=
 me who don&#39;t have good memories.=C2=A0 Specifically, having two parame=
ters of the same type (that are not commutative).=C2=A0 I would likely be c=
onstantly looking up the right parameter order.=C2=A0 And if I ddin&#39;t l=
ook it up and got it wrong, that would be a run-time bug, potentially one t=
hat was very hard to find.<br><br>On Friday, December 9, 2016 at 4:21:28 AM=
 UTC-5, Dawid Pilarski wrote:<blockquote class=3D"gmail_quote" style=3D"mar=
gin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div d=
ir=3D"ltr"><code>I do not quite like the idea of operator + and operator -.=
 It&#39;s kind of misleading, that operator + and - has so strange meaning.=
 Why not doing just simple function round_up_to_multiple, which would have =
cleaner interface?</code><code><span style=3D"color:rgb(0,0,0)"><br><br></s=
pan></code></div><div><br><div class=3D"gmail_quote">2016-12-08 19:39 GMT+0=
1:00 &#39;Walt Karas&#39; via ISO C++ Standard - Future Proposals <span dir=
=3D"ltr">&lt;<a rel=3D"nofollow">std-pr...@isocpp.org</a>&gt;</span>:<br><b=
lockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px =
#ccc solid;padding-left:1ex"><div dir=3D"ltr"><div style=3D"background-colo=
r:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-=
width:1px;word-wrap:break-word"><code><div><span style=3D"color:#800">#incl=
ude</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&lt=
;type_traits&gt;</span><span style=3D"color:#000"><br><br><br></span><span =
style=3D"color:#008">template</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span=
><span style=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#008">struct</sp=
an><span style=3D"color:#000"> mround_type<br>=C2=A0 </span><span style=3D"=
color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</s=
pan><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span sty=
le=3D"color:#660">::</span><span style=3D"color:#000">is_integral</span><sp=
an style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</span><span=
 style=3D"color:#660">&gt;::</span><span style=3D"color:#000">value</span><=
span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span =
style=3D"color:#080">&quot;mround_type requires integral type&quot;</span><=
span style=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#008">const</span><span style=3D"=
color:#000"> I value</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008"=
>constexpr</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">explicit</span><span style=3D"color:#000"> mround_type</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#000">I v</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">:</span><span style=3D"color:#000"> value</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#000">v</span><span style=3D"color:=
#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
>{</span><span style=3D"color:#000"> </span><span style=3D"color:#660">}</s=
pan><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660"=
>};</span><span style=3D"color:#000"><br><br><br></span><span style=3D"colo=
r:#008">template</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#660">&lt;</span><span style=3D"color:#008">typename</span><span style=
=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#008">auto</span><span s=
tyle=3D"color:#000"> mround</span><span style=3D"color:#660">(</span><span =
style=3D"color:#000">I i</span><span style=3D"color:#660">)</span><span sty=
le=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</span><spa=
n style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">=
static_assert</span><span style=3D"color:#660">(</span><span style=3D"color=
:#000"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</sp=
an><span style=3D"color:#000">is_integral</span><span style=3D"color:#660">=
&lt;</span><span style=3D"color:#000">I</span><span style=3D"color:#660">&g=
t;::</span><span style=3D"color:#000">value</span><span style=3D"color:#660=
">,</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 </span><span =
style=3D"color:#080">&quot;mround() parameter must be of integral type&quot=
;</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=
<br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span =
style=3D"color:#660">(</span><span style=3D"color:#000">mround_type</span><=
span style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</span><sp=
an style=3D"color:#660">&gt;(</span><span style=3D"color:#000">i</span><spa=
n style=3D"color:#660">));</span><span style=3D"color:#000"><br>=C2=A0 </sp=
an><span style=3D"color:#660">}</span><span style=3D"color:#000"><br><br><b=
r></span><span style=3D"color:#800">// Rounded-up integral division.</span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#008">template</=
span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</sp=
an><span style=3D"color:#008">typename</span><span style=3D"color:#000"> I<=
/span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br>=
</span><span style=3D"color:#008">constexpr</span><span style=3D"color:#000=
"> I </span><span style=3D"color:#008">operator</span><span style=3D"color:=
#000"> </span><span style=3D"color:#660">/</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">(</span><span style=3D"color:#000">I i<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> mround=
_type</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000=
">I</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000">=
 factor</span><span style=3D"color:#660">)</span><span style=3D"color:#000"=
><br>=C2=A0 </span><span style=3D"color:#660">{</span><span style=3D"color:=
#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><spa=
n style=3D"color:#660">((</span><span style=3D"color:#000">i </span><span s=
tyle=3D"color:#660">+</span><span style=3D"color:#000"> factor</span><span =
style=3D"color:#660">.</span><span style=3D"color:#000">value </span><span =
style=3D"color:#660">-</span><span style=3D"color:#000"> </span><span style=
=3D"color:#066">1</span><span style=3D"color:#660">)</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">/</span><span style=3D"color:=
#000"> factor</span><span style=3D"color:#660">.</span><span style=3D"color=
:#000">value</span><span style=3D"color:#660">);</span><span style=3D"color=
:#000"><br>=C2=A0 </span><span style=3D"color:#660">}</span><span style=3D"=
color:#000"><br><br><br></span><span style=3D"color:#800">// Round up integ=
er to multiple.</span><span style=3D"color:#000"><br></span><span style=3D"=
color:#008">template</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><span =
style=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><span s=
tyle=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</span><=
span style=3D"color:#000"> I </span><span style=3D"color:#008">operator</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">+</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span s=
tyle=3D"color:#000">I i</span><span style=3D"color:#660">,</span><span styl=
e=3D"color:#000"> mround_type</span><span style=3D"color:#660">&lt;</span><=
span style=3D"color:#000">I</span><span style=3D"color:#660">&gt;</span><sp=
an style=3D"color:#000"> factor</span><span style=3D"color:#660">)</span><s=
pan style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color=
:#008">return</span><span style=3D"color:#660">((</span><span style=3D"colo=
r:#000">i </span><span style=3D"color:#660">/</span><span style=3D"color:#0=
00"> factor</span><span style=3D"color:#660">)</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">*</span><span style=3D"color:#000">=
 factor</span><span style=3D"color:#660">.</span><span style=3D"color:#000"=
>value</span><span style=3D"color:#660">);</span><span style=3D"color:#000"=
><br>=C2=A0 </span><span style=3D"color:#660">}</span><span style=3D"color:=
#000"><br><br><br></span><span style=3D"color:#800">// Round down integer t=
o multiple.</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#008">template</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#660">&lt;</span><span style=3D"color:#008">typename</span><span style=
=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</span><span=
 style=3D"color:#000"> I </span><span style=3D"color:#008">operator</span><=
span style=3D"color:#000"> </span><span style=3D"color:#660">-</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">I i</span><span style=3D"color:#660">,</span><span style=3D=
"color:#000"> mround_type</span><span style=3D"color:#660">&lt;</span><span=
 style=3D"color:#000">I</span><span style=3D"color:#660">&gt;</span><span s=
tyle=3D"color:#000"> factor</span><span style=3D"color:#660">)</span><span =
style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</span><=
span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#00=
8">return</span><span style=3D"color:#660">(</span><span style=3D"color:#00=
0">i </span><span style=3D"color:#660">-</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">(</span><span style=3D"color:#000">i </sp=
an><span style=3D"color:#660">%</span><span style=3D"color:#000"> factor</s=
pan><span style=3D"color:#660">.</span><span style=3D"color:#000">value</sp=
an><span style=3D"color:#660">));</span><span style=3D"color:#000"><br>=C2=
=A0 </span><span style=3D"color:#660">}</span><span style=3D"color:#000"><b=
r><br><br></span><span style=3D"color:#008">static_assert</span><span style=
=3D"color:#660">(</span><span style=3D"color:#066">9</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">/</span><span style=3D"color:=
#000"> mround</span><span style=3D"color:#660">(</span><span style=3D"color=
:#066">5</span><span style=3D"color:#660">)</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000=
"> </span><span style=3D"color:#066">2</span><span style=3D"color:#660">,</=
span><span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&q=
uot;</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><=
br></span><span style=3D"color:#008">static_assert</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#066">10</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">/</span><span style=3D"color:#000">=
 mround</span><span style=3D"color:#660">(</span><span style=3D"color:#066"=
>5</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#066">2</span><span style=3D"color:#660">,</span><=
span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</=
span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br></s=
pan><span style=3D"color:#008">static_assert</span><span style=3D"color:#66=
0">(</span><span style=3D"color:#066">11</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">/</span><span style=3D"color:#000"> mroun=
d</span><span style=3D"color:#660">(</span><span style=3D"color:#066">5</sp=
an><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#066">3</span><span style=3D"color:#660">,</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><=
span style=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br><=
/span><span style=3D"color:#008">static_assert</span><span style=3D"color:#=
660">(</span><span style=3D"color:#066">9</span><span style=3D"color:#000">=
 </span><span style=3D"color:#660">+</span><span style=3D"color:#000"> mrou=
nd</span><span style=3D"color:#660">(</span><span style=3D"color:#066">5</s=
pan><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><=
span style=3D"color:#066">10</span><span style=3D"color:#660">,</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span=
><span style=3D"color:#660">);</span><span style=3D"color:#000"><br></span>=
<span style=3D"color:#008">static_assert</span><span style=3D"color:#660">(=
</span><span style=3D"color:#066">10</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">+</span><span style=3D"color:#000"> mround</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#066">5</span><=
span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span =
style=3D"color:#066">10</span><span style=3D"color:#660">,</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><spa=
n style=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span=
 style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</spa=
n><span style=3D"color:#066">11</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">+</span><span style=3D"color:#000"> mround</span><=
span style=3D"color:#660">(</span><span style=3D"color:#066">5</span><span =
style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=
=3D"color:#066">15</span><span style=3D"color:#660">,</span><span style=3D"=
color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span sty=
le=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br></span><s=
pan style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</=
span><span style=3D"color:#066">9</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">-</span><span style=3D"color:#000"> mround</span=
><span style=3D"color:#660">(</span><span style=3D"color:#066">5</span><spa=
n style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#066">5</span><span style=3D"color:#660">,</span><span style=3D=
"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span st=
yle=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span sty=
le=3D"color:#008">static_assert</span><span style=3D"color:#660">(</span><s=
pan style=3D"color:#066">10</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">-</span><span style=3D"color:#000"> mround</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#066">5</span><span styl=
e=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"=
color:#066">10</span><span style=3D"color:#660">,</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=
=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">static_assert</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#066">11</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">-</span><span style=3D"color:#000"> mround</span><span s=
tyle=3D"color:#660">(</span><span style=3D"color:#066">5</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#066">10</span><span style=3D"color:#660">,</span><span style=3D"color=
:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=3D=
"color:#660">);</span><span><font color=3D"#888888"><span style=3D"color:#0=
00"><br></span><span style=3D"color:#000"><br></span></font></span></div></=
code></div><span><font color=3D"#888888"><div><br><br></div></font></span><=
/div><span><font color=3D"#888888">

<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 rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</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/1af197bf-4e85-4e4b-9486-dd7ca150c139%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/1af197bf-4e85-4e4b-<wbr>9486-=
dd7ca150c139%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br></div>
</blockquote></div></blockquote></div></div></div></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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
Q0DlErUbCQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"Q0DlErUbCQAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@isocpp.org</a>.<br></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/5b05d62b-b1ff-42f5-<wbr>a929-=
e35d697c4869%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div>
</blockquote></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/be7fb134-efa2-4f35-aa0f-51b11efc52da%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/be7fb134-efa2-4f35-aa0f-51b11efc52da=
%40isocpp.org</a>.<br />

------=_Part_1254_2143755811.1481556189753--

------=_Part_1253_1682199006.1481556189751--

.


Author: Dawid Pilarski <dawidpicpp@gmail.com>
Date: Tue, 13 Dec 2016 09:58:15 +0100
Raw View
--001a1147e072c2e8a80543866b21
Content-Type: text/plain; charset=UTF-8

It can be simple type like:

//using new class template deduction
template <typename T>
class Value{
public:
    explicit Value(T value);
    operator T (); //or simple T value() method
private
T storedValue;
};


same would be for Factor type.
Purpuse of this class would be only for syntax sugaring function call, so

round_up_multiple(2,3) // error, because constructor is explicit
round_up_multiple(Value(2), Factor(3)); // fine

also declaration of such a function will have to be templated, so

template <typename T>
T round_up_multiple(Value<T>, Factor<T>);

2016-12-12 16:23 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future
Proposals <std-proposals@isocpp.org>:

> I don't see how that would work.  Are Value and Factor concepts rather
> than templates in your suggestion?  I only have a very rough idea of what's
> in the Concepts TS.
>
> On Monday, December 12, 2016 at 3:51:08 AM UTC-5, Dawid Pilarski wrote:
>>
>> How about interface like this:
>>
>> Integral round_up_to_multiple(Value i, Factor factor);
>>
>> With both Value and Factor having explicit constructors.
>> which should be called like this:
>> round_up_to_multiple(Value(x), Factor(y));
>>
>> In fact there is no need here to introduce mround type. But I do not say
>> it's bad here, although Value and Factor is IMO more expressive.
>> It's still just an idea.
>>
>> On the other hand, It would be strange also to introduce double
>> interface.
>> First for / and * operators with just mround type and add and subtract
>> with functions. It's inconsistent IMO, however I myself gave this
>> suggestion. I think the API should be considered harder.
>>
>> 2016-12-10 22:40 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future
>> Proposals <std-pr...@isocpp.org>:
>>
>>> How about this alternative?
>>>
>>> #include <type_traits>
>>>
>>> template <typename I>
>>> struct mround_type
>>>   {
>>>     static_assert(
>>>       std::is_integral<I>::value, "mround_type requires integral type");
>>>
>>>     const I value;
>>>
>>>     constexpr explicit mround_type(I v) : value(v) { }
>>>
>>>     // Rounded-up integral division.
>>>     constexpr I div(I factor)
>>>       {
>>>         return((value + factor - 1) / factor);
>>>       }
>>>
>>>     // Round up integer to multiple.
>>>     constexpr I up(I factor)
>>>       {
>>>         return(div(factor) * factor);
>>>       }
>>>
>>>     // Round down integer to multiple.
>>>     constexpr I down(I factor)
>>>       {
>>>         return(value - (value % factor));
>>>       }
>>>   };
>>>
>>> template <typename I>
>>> constexpr auto mround(I i)
>>>   {
>>>     static_assert(
>>>       std::is_integral<I>::value,
>>>       "mround() parameter must be of integral type");
>>>
>>>     return(mround_type<I>(i));
>>>   }
>>>
>>> static_assert(mround(9).div(5) == 2, "");
>>> static_assert(mround(10).div(5) == 2, "");
>>> static_assert(mround(11).div(5) == 3, "");
>>>
>>> static_assert(mround(9).up(5) == 10, "");
>>> static_assert(mround(10).up(5) == 10, "");
>>> static_assert(mround(11).up(5) == 15, "");
>>>
>>> static_assert(mround(9).down(5) == 5, "");
>>> static_assert(mround(10).down(5) == 10, "");
>>> static_assert(mround(11).down(5) == 10, "");
>>>
>>>
>>>
>>>
>>> On Friday, December 9, 2016 at 11:30:40 AM UTC-5, Walt Karas wrote:
>>>
>>>> I take your point, it has validity.  But round_up_to_multiple(Integral,
>>>> Integral) has issues for people like me who don't have good memories.
>>>> Specifically, having two parameters of the same type (that are not
>>>> commutative).  I would likely be constantly looking up the right parameter
>>>> order.  And if I ddin't look it up and got it wrong, that would be a
>>>> run-time bug, potentially one that was very hard to find.
>>>>
>>>> On Friday, December 9, 2016 at 4:21:28 AM UTC-5, Dawid Pilarski wrote:
>>>>>
>>>>> I do not quite like the idea of operator + and operator -. It's kind
>>>>> of misleading, that operator + and - has so strange meaning. Why not doing
>>>>> just simple function round_up_to_multiple, which would have cleaner
>>>>> interface?
>>>>>
>>>>>
>>>>> 2016-12-08 19:39 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future
>>>>> Proposals <std-pr...@isocpp.org>:
>>>>>
>>>>>> #include <type_traits>
>>>>>>
>>>>>>
>>>>>> template <typename I>
>>>>>> struct mround_type
>>>>>>   {
>>>>>>     static_assert(
>>>>>>       std::is_integral<I>::value, "mround_type requires integral
>>>>>> type");
>>>>>>
>>>>>>
>>>>>>     const I value;
>>>>>>
>>>>>>
>>>>>>     constexpr explicit mround_type(I v) : value(v) { }
>>>>>>   };
>>>>>>
>>>>>>
>>>>>> template <typename I>
>>>>>> constexpr auto mround(I i)
>>>>>>   {
>>>>>>     static_assert(
>>>>>>       std::is_integral<I>::value,
>>>>>>       "mround() parameter must be of integral type");
>>>>>>
>>>>>>
>>>>>>     return(mround_type<I>(i));
>>>>>>   }
>>>>>>
>>>>>>
>>>>>> // Rounded-up integral division.
>>>>>> template <typename I>
>>>>>> constexpr I operator / (I i, mround_type<I> factor)
>>>>>>   {
>>>>>>     return((i + factor.value - 1) / factor.value);
>>>>>>   }
>>>>>>
>>>>>>
>>>>>> // Round up integer to multiple.
>>>>>> template <typename I>
>>>>>> constexpr I operator + (I i, mround_type<I> factor)
>>>>>>   {
>>>>>>     return((i / factor) * factor.value);
>>>>>>   }
>>>>>>
>>>>>>
>>>>>> // Round down integer to multiple.
>>>>>> template <typename I>
>>>>>> constexpr I operator - (I i, mround_type<I> factor)
>>>>>>   {
>>>>>>     return(i - (i % factor.value));
>>>>>>   }
>>>>>>
>>>>>>
>>>>>> static_assert(9 / mround(5) == 2, "");
>>>>>> static_assert(10 / mround(5) == 2, "");
>>>>>> static_assert(11 / mround(5) == 3, "");
>>>>>>
>>>>>>
>>>>>> static_assert(9 + mround(5) == 10, "");
>>>>>> static_assert(10 + mround(5) == 10, "");
>>>>>> static_assert(11 + mround(5) == 15, "");
>>>>>>
>>>>>>
>>>>>> static_assert(9 - mround(5) == 5, "");
>>>>>> static_assert(10 - mround(5) == 10, "");
>>>>>> static_assert(11 - mround(5) == 10, "");
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> 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-proposal...@isocpp.org.
>>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals
>>>>>> /1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org
>>>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>>
>>>>> --
>>> 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-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> To view this discussion on the web visit https://groups.google.com/a/is
>>> ocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-
>>> e35d697c4869%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%40isocpp.org?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>> --
> 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/be7fb134-efa2-4f35-
> aa0f-51b11efc52da%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/be7fb134-efa2-4f35-aa0f-51b11efc52da%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
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/CAOkZZiG%2BtM8xU3Hj2ui48hXd72sVh9Aq_oUDxpcb_%2BSassUUMw%40mail.gmail.com.

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

<div dir=3D"ltr"><div><div><div><div><div>It can be simple type like:<br><b=
r></div><div>//using new class template deduction<br></div>template &lt;typ=
ename T&gt;<br></div>class Value{<br></div>public:<br></div>=C2=A0=C2=A0=C2=
=A0 explicit Value(T value);<br></div><div>=C2=A0=C2=A0=C2=A0 operator T ()=
; //or simple T value() method<br></div><div>private<br></div>T storedValue=
;<br><div><div><div><div>};<br><br><br></div><div>same would be for Factor =
type. <br></div><div>Purpuse of this class would be only for syntax sugarin=
g function call, so<br><br></div><div>round_up_multiple(2,3) // error, beca=
use constructor is explicit<br></div><div>round_up_multiple(Value(2), Facto=
r(3)); // fine <br><br></div><div>also declaration of such a function will =
have to be templated, so<br><br></div><div>template &lt;typename T&gt;<br><=
/div><div>T round_up_multiple(Value&lt;T&gt;, Factor&lt;T&gt;);<br></div></=
div></div></div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_qu=
ote">2016-12-12 16:23 GMT+01:00 &#39;Walt Karas&#39; via ISO C++ Standard -=
 Future Proposals <span dir=3D"ltr">&lt;<a href=3D"mailto:std-proposals@iso=
cpp.org" target=3D"_blank">std-proposals@isocpp.org</a>&gt;</span>:<br><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div dir=3D"ltr">I don&#39;t see how that would =
work.=C2=A0 Are Value and Factor concepts rather than templates in your sug=
gestion?=C2=A0 I only have a very rough idea of what&#39;s in the Concepts =
TS.<div><span class=3D""><br>On Monday, December 12, 2016 at 3:51:08 AM UTC=
-5, Dawid Pilarski wrote:</span><blockquote class=3D"gmail_quote" style=3D"=
margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><sp=
an class=3D""><div dir=3D"ltr"><div><div><div>How about interface like this=
:<br><br>Integral round_up_to_multiple(Value i, Factor factor); <br><br></d=
iv><div>With both Value and Factor having explicit constructors.<br></div>w=
hich should be called like this:<br>round_up_to_multiple(Value(x), Factor(y=
));<br><br></div>In fact there is no need here to introduce mround type. Bu=
t I do not say it&#39;s bad here, although Value and Factor is IMO more exp=
ressive.<br></div><div>It&#39;s still just an idea.<br><br></div><div>On th=
e other hand, It would be strange also to introduce double interface. <br><=
/div><div>First for / and * operators with just mround type and add and sub=
tract with functions. It&#39;s inconsistent IMO, however I myself gave this=
 suggestion. I think the API should be considered harder.<br></div></div></=
span><div><br><div class=3D"gmail_quote"><div><div class=3D"h5">2016-12-10 =
22:40 GMT+01:00 &#39;Walt Karas&#39; via ISO C++ Standard - Future Proposal=
s <span dir=3D"ltr">&lt;<a rel=3D"nofollow">std-pr...@isocpp.org</a>&gt;</s=
pan>:<br></div></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 =
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class=3D"h5">=
<div dir=3D"ltr">How about this alternative?<div><br></div><div><div style=
=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-=
style:solid;border-width:1px;word-wrap:break-word"><code><div><span><div><f=
ont color=3D"#660066">#include &lt;type_traits&gt;</font></div><div><font c=
olor=3D"#660066"><br></font></div><div><font color=3D"#660066">template &lt=
;typename I&gt;</font></div><div><font color=3D"#660066">struct mround_type=
</font></div><div><font color=3D"#660066">=C2=A0 {</font></div><div><font c=
olor=3D"#660066">=C2=A0 =C2=A0 static_assert(</font></div><div><font color=
=3D"#660066">=C2=A0 =C2=A0 =C2=A0 std::is_integral&lt;I&gt;::value, &quot;m=
round_type requires integral type&quot;);</font></div><div><font color=3D"#=
660066"><br></font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 const I=
 value;</font></div><div><font color=3D"#660066"><br></font></div><div><fon=
t color=3D"#660066">=C2=A0 =C2=A0 constexpr explicit mround_type(I v) : val=
ue(v) { }</font></div><div><font color=3D"#660066"><br></font></div></span>=
<div><font color=3D"#660066">=C2=A0 =C2=A0 // Rounded-up integral division.=
</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 constexpr I div(I f=
actor)</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 {</fon=
t></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return((va=
lue + factor - 1) / factor);</font></div><span><div><font color=3D"#660066"=
>=C2=A0 =C2=A0 =C2=A0 }</font></div><div><font color=3D"#660066"><br></font=
></div><div><font color=3D"#660066">=C2=A0 =C2=A0 // Round up integer to mu=
ltiple.</font></div></span><div><font color=3D"#660066">=C2=A0 =C2=A0 const=
expr I up(I factor)</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =
=C2=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 return(div(factor) * factor);</font></div><span><div><font color=3D"#66=
0066">=C2=A0 =C2=A0 =C2=A0 }</font></div><div><font color=3D"#660066"><br><=
/font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 // Round down intege=
r to multiple.</font></div></span><div><font color=3D"#660066">=C2=A0 =C2=
=A0 constexpr I down(I factor)</font></div><div><font color=3D"#660066">=C2=
=A0 =C2=A0 =C2=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 return(value - (value % factor));</font></div><span><div><fon=
t color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 }</font></div><div><font color=3D"=
#660066">=C2=A0 };</font></div><div><font color=3D"#660066"><br></font></di=
v><div><font color=3D"#660066">template &lt;typename I&gt;</font></div><div=
><font color=3D"#660066">constexpr auto mround(I i)</font></div><div><font =
color=3D"#660066">=C2=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =
=C2=A0 static_assert(</font></div><div><font color=3D"#660066">=C2=A0 =C2=
=A0 =C2=A0 std::is_integral&lt;I&gt;::value,</font></div><div><font color=
=3D"#660066">=C2=A0 =C2=A0 =C2=A0 &quot;mround() parameter must be of integ=
ral type&quot;);</font></div><div><font color=3D"#660066"><br></font></div>=
<div><font color=3D"#660066">=C2=A0 =C2=A0 return(mround_type&lt;I&gt;(i));=
</font></div><div><font color=3D"#660066">=C2=A0 }</font></div><div><font c=
olor=3D"#660066"><br></font></div></span><div><font color=3D"#660066">stati=
c_assert(mround(9).div(5) =3D=3D 2, &quot;&quot;);</font></div><div><font c=
olor=3D"#660066">static_assert(mround(10).div(5<wbr>) =3D=3D 2, &quot;&quot=
;);</font></div><div><font color=3D"#660066">static_assert(mround(11).div(5=
<wbr>) =3D=3D 3, &quot;&quot;);</font></div><div><font color=3D"#660066"><b=
r></font></div><div><font color=3D"#660066">static_assert(mround(9).up(5) =
=3D=3D 10, &quot;&quot;);</font></div><div><font color=3D"#660066">static_a=
ssert(mround(10).up(5) =3D=3D 10, &quot;&quot;);</font></div><div><font col=
or=3D"#660066">static_assert(mround(11).up(5) =3D=3D 15, &quot;&quot;);</fo=
nt></div><div><font color=3D"#660066"><br></font></div><div><font color=3D"=
#660066">static_assert(mround(9).down(5<wbr>) =3D=3D 5, &quot;&quot;);</fon=
t></div><div><font color=3D"#660066">static_assert(mround(10).down(<wbr>5) =
=3D=3D 10, &quot;&quot;);</font></div><div><font color=3D"#660066">static_a=
ssert(mround(11).down(<wbr>5) =3D=3D 10, &quot;&quot;);</font></div><div><b=
r></div></div></code></div><span><br><br><br>On Friday, December 9, 2016 at=
 11:30:40 AM UTC-5, Walt Karas wrote:</span><div><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">I take your point, it has validity.=C2=
=A0 But round_up_to_multiple(Integral, Integral) has issues for people like=
 me who don&#39;t have good memories.=C2=A0 Specifically, having two parame=
ters of the same type (that are not commutative).=C2=A0 I would likely be c=
onstantly looking up the right parameter order.=C2=A0 And if I ddin&#39;t l=
ook it up and got it wrong, that would be a run-time bug, potentially one t=
hat was very hard to find.<br><br>On Friday, December 9, 2016 at 4:21:28 AM=
 UTC-5, Dawid Pilarski wrote:<blockquote class=3D"gmail_quote" style=3D"mar=
gin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div d=
ir=3D"ltr"><code>I do not quite like the idea of operator + and operator -.=
 It&#39;s kind of misleading, that operator + and - has so strange meaning.=
 Why not doing just simple function round_up_to_multiple, which would have =
cleaner interface?</code><code><span style=3D"color:rgb(0,0,0)"><br><br></s=
pan></code></div><div><br><div class=3D"gmail_quote">2016-12-08 19:39 GMT+0=
1:00 &#39;Walt Karas&#39; via ISO C++ Standard - Future Proposals <span dir=
=3D"ltr">&lt;<a rel=3D"nofollow">std-pr...@isocpp.org</a>&gt;</span>:<br><b=
lockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px =
#ccc solid;padding-left:1ex"><div dir=3D"ltr"><div style=3D"background-colo=
r:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-=
width:1px;word-wrap:break-word"><code><div><span style=3D"color:#800">#incl=
ude</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&lt=
;type_traits&gt;</span><span style=3D"color:#000"><br><br><br></span><span =
style=3D"color:#008">template</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span=
><span style=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#008">struct</sp=
an><span style=3D"color:#000"> mround_type<br>=C2=A0 </span><span style=3D"=
color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</s=
pan><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span sty=
le=3D"color:#660">::</span><span style=3D"color:#000">is_integral</span><sp=
an style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</span><span=
 style=3D"color:#660">&gt;::</span><span style=3D"color:#000">value</span><=
span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span =
style=3D"color:#080">&quot;mround_type requires integral type&quot;</span><=
span style=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#008">const</span><span style=3D"=
color:#000"> I value</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008"=
>constexpr</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">explicit</span><span style=3D"color:#000"> mround_type</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#000">I v</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">:</span><span style=3D"color:#000"> value</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#000">v</span><span style=3D"color:=
#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
>{</span><span style=3D"color:#000"> </span><span style=3D"color:#660">}</s=
pan><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660"=
>};</span><span style=3D"color:#000"><br><br><br></span><span style=3D"colo=
r:#008">template</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#660">&lt;</span><span style=3D"color:#008">typename</span><span style=
=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#008">auto</span><span s=
tyle=3D"color:#000"> mround</span><span style=3D"color:#660">(</span><span =
style=3D"color:#000">I i</span><span style=3D"color:#660">)</span><span sty=
le=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</span><spa=
n style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">=
static_assert</span><span style=3D"color:#660">(</span><span style=3D"color=
:#000"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</sp=
an><span style=3D"color:#000">is_integral</span><span style=3D"color:#660">=
&lt;</span><span style=3D"color:#000">I</span><span style=3D"color:#660">&g=
t;::</span><span style=3D"color:#000">value</span><span style=3D"color:#660=
">,</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 </span><span =
style=3D"color:#080">&quot;mround() parameter must be of integral type&quot=
;</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=
<br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span =
style=3D"color:#660">(</span><span style=3D"color:#000">mround_type</span><=
span style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</span><sp=
an style=3D"color:#660">&gt;(</span><span style=3D"color:#000">i</span><spa=
n style=3D"color:#660">));</span><span style=3D"color:#000"><br>=C2=A0 </sp=
an><span style=3D"color:#660">}</span><span style=3D"color:#000"><br><br><b=
r></span><span style=3D"color:#800">// Rounded-up integral division.</span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#008">template</=
span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</sp=
an><span style=3D"color:#008">typename</span><span style=3D"color:#000"> I<=
/span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br>=
</span><span style=3D"color:#008">constexpr</span><span style=3D"color:#000=
"> I </span><span style=3D"color:#008">operator</span><span style=3D"color:=
#000"> </span><span style=3D"color:#660">/</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">(</span><span style=3D"color:#000">I i<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> mround=
_type</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000=
">I</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000">=
 factor</span><span style=3D"color:#660">)</span><span style=3D"color:#000"=
><br>=C2=A0 </span><span style=3D"color:#660">{</span><span style=3D"color:=
#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><spa=
n style=3D"color:#660">((</span><span style=3D"color:#000">i </span><span s=
tyle=3D"color:#660">+</span><span style=3D"color:#000"> factor</span><span =
style=3D"color:#660">.</span><span style=3D"color:#000">value </span><span =
style=3D"color:#660">-</span><span style=3D"color:#000"> </span><span style=
=3D"color:#066">1</span><span style=3D"color:#660">)</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">/</span><span style=3D"color:=
#000"> factor</span><span style=3D"color:#660">.</span><span style=3D"color=
:#000">value</span><span style=3D"color:#660">);</span><span style=3D"color=
:#000"><br>=C2=A0 </span><span style=3D"color:#660">}</span><span style=3D"=
color:#000"><br><br><br></span><span style=3D"color:#800">// Round up integ=
er to multiple.</span><span style=3D"color:#000"><br></span><span style=3D"=
color:#008">template</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><span =
style=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><span s=
tyle=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</span><=
span style=3D"color:#000"> I </span><span style=3D"color:#008">operator</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">+</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span s=
tyle=3D"color:#000">I i</span><span style=3D"color:#660">,</span><span styl=
e=3D"color:#000"> mround_type</span><span style=3D"color:#660">&lt;</span><=
span style=3D"color:#000">I</span><span style=3D"color:#660">&gt;</span><sp=
an style=3D"color:#000"> factor</span><span style=3D"color:#660">)</span><s=
pan style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color=
:#008">return</span><span style=3D"color:#660">((</span><span style=3D"colo=
r:#000">i </span><span style=3D"color:#660">/</span><span style=3D"color:#0=
00"> factor</span><span style=3D"color:#660">)</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">*</span><span style=3D"color:#000">=
 factor</span><span style=3D"color:#660">.</span><span style=3D"color:#000"=
>value</span><span style=3D"color:#660">);</span><span style=3D"color:#000"=
><br>=C2=A0 </span><span style=3D"color:#660">}</span><span style=3D"color:=
#000"><br><br><br></span><span style=3D"color:#800">// Round down integer t=
o multiple.</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#008">template</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#660">&lt;</span><span style=3D"color:#008">typename</span><span style=
=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</span><span=
 style=3D"color:#000"> I </span><span style=3D"color:#008">operator</span><=
span style=3D"color:#000"> </span><span style=3D"color:#660">-</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">I i</span><span style=3D"color:#660">,</span><span style=3D=
"color:#000"> mround_type</span><span style=3D"color:#660">&lt;</span><span=
 style=3D"color:#000">I</span><span style=3D"color:#660">&gt;</span><span s=
tyle=3D"color:#000"> factor</span><span style=3D"color:#660">)</span><span =
style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</span><=
span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#00=
8">return</span><span style=3D"color:#660">(</span><span style=3D"color:#00=
0">i </span><span style=3D"color:#660">-</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">(</span><span style=3D"color:#000">i </sp=
an><span style=3D"color:#660">%</span><span style=3D"color:#000"> factor</s=
pan><span style=3D"color:#660">.</span><span style=3D"color:#000">value</sp=
an><span style=3D"color:#660">));</span><span style=3D"color:#000"><br>=C2=
=A0 </span><span style=3D"color:#660">}</span><span style=3D"color:#000"><b=
r><br><br></span><span style=3D"color:#008">static_assert</span><span style=
=3D"color:#660">(</span><span style=3D"color:#066">9</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">/</span><span style=3D"color:=
#000"> mround</span><span style=3D"color:#660">(</span><span style=3D"color=
:#066">5</span><span style=3D"color:#660">)</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000=
"> </span><span style=3D"color:#066">2</span><span style=3D"color:#660">,</=
span><span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&q=
uot;</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><=
br></span><span style=3D"color:#008">static_assert</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#066">10</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">/</span><span style=3D"color:#000">=
 mround</span><span style=3D"color:#660">(</span><span style=3D"color:#066"=
>5</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#066">2</span><span style=3D"color:#660">,</span><=
span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</=
span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br></s=
pan><span style=3D"color:#008">static_assert</span><span style=3D"color:#66=
0">(</span><span style=3D"color:#066">11</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">/</span><span style=3D"color:#000"> mroun=
d</span><span style=3D"color:#660">(</span><span style=3D"color:#066">5</sp=
an><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#066">3</span><span style=3D"color:#660">,</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><=
span style=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br><=
/span><span style=3D"color:#008">static_assert</span><span style=3D"color:#=
660">(</span><span style=3D"color:#066">9</span><span style=3D"color:#000">=
 </span><span style=3D"color:#660">+</span><span style=3D"color:#000"> mrou=
nd</span><span style=3D"color:#660">(</span><span style=3D"color:#066">5</s=
pan><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><=
span style=3D"color:#066">10</span><span style=3D"color:#660">,</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span=
><span style=3D"color:#660">);</span><span style=3D"color:#000"><br></span>=
<span style=3D"color:#008">static_assert</span><span style=3D"color:#660">(=
</span><span style=3D"color:#066">10</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">+</span><span style=3D"color:#000"> mround</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#066">5</span><=
span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span =
style=3D"color:#066">10</span><span style=3D"color:#660">,</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><spa=
n style=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span=
 style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</spa=
n><span style=3D"color:#066">11</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">+</span><span style=3D"color:#000"> mround</span><=
span style=3D"color:#660">(</span><span style=3D"color:#066">5</span><span =
style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=
=3D"color:#066">15</span><span style=3D"color:#660">,</span><span style=3D"=
color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span sty=
le=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br></span><s=
pan style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</=
span><span style=3D"color:#066">9</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">-</span><span style=3D"color:#000"> mround</span=
><span style=3D"color:#660">(</span><span style=3D"color:#066">5</span><spa=
n style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#066">5</span><span style=3D"color:#660">,</span><span style=3D=
"color:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span st=
yle=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span sty=
le=3D"color:#008">static_assert</span><span style=3D"color:#660">(</span><s=
pan style=3D"color:#066">10</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">-</span><span style=3D"color:#000"> mround</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#066">5</span><span styl=
e=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"=
color:#066">10</span><span style=3D"color:#660">,</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=
=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">static_assert</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#066">11</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">-</span><span style=3D"color:#000"> mround</span><span s=
tyle=3D"color:#660">(</span><span style=3D"color:#066">5</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#066">10</span><span style=3D"color:#660">,</span><span style=3D"color=
:#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=3D=
"color:#660">);</span><span><font color=3D"#888888"><span style=3D"color:#0=
00"><br></span><span style=3D"color:#000"><br></span></font></span></div></=
code></div><span><font color=3D"#888888"><div><br><br></div></font></span><=
/div><span><font color=3D"#888888">

<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 rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</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/1af197bf-4e85-4e4b-9486-dd7ca150c139%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-pr=
oposals<wbr>/1af197bf-4e85-4e4b-9486-<wbr>dd7ca150c139%40isocpp.org</a>.<br=
>
</font></span></blockquote></div><br></div>
</blockquote></div></blockquote></div></div></div></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 rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</a>.<br></div></div></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-pr=
oposals<wbr>/5b05d62b-b1ff-42f5-a929-<wbr>e35d697c4869%40isocpp.org</a>.<br=
>
</blockquote></div><br></div>
</blockquote></div></div><span class=3D"">

<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/be7fb134-efa2-4f35-aa0f-51b11efc52da%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/be7f=
b134-efa2-4f35-<wbr>aa0f-51b11efc52da%40isocpp.org</a><wbr>.<br>
</blockquote></div><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/CAOkZZiG%2BtM8xU3Hj2ui48hXd72sVh9Aq_o=
UDxpcb_%2BSassUUMw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOkZZiG%2BtM=
8xU3Hj2ui48hXd72sVh9Aq_oUDxpcb_%2BSassUUMw%40mail.gmail.com</a>.<br />

--001a1147e072c2e8a80543866b21--

.


Author: "'Walt Karas' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Tue, 13 Dec 2016 07:44:27 -0800 (PST)
Raw View
------=_Part_1816_2111119432.1481643867271
Content-Type: multipart/alternative;
 boundary="----=_Part_1817_453921513.1481643867273"

------=_Part_1817_453921513.1481643867273
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Can you give a compiling example?

It seems to me that my helper function template in indispensible:

template <typename T>
struct X
{ explicit X(T t); };


template <typename T>
void foo(X<T> x);


void bar() { foo(X(5)); } // causes an error


template <typename T>
X<T> x(T t) { return(X<T>(5)); }


void bar2() { foo(x(5)); }

Link to Compiler Explorer:

https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,options:(colouriseA=
sm:'0',compileOnChange:'0'),source:'template+%3Ctypename+T%3E%0Astruct+X%0A=
%7B+explicit+X(T+t)%3B+%7D%3B%0A%0Atemplate+%3Ctypename+T%3E%0Avoid+foo(X%3=
CT%3E+x)%3B%0A%0Avoid+bar()+%7B+foo(X(5))%3B+%7D%0A%0Atemplate+%3Ctypename+=
T%3E%0AX%3CT%3E+x(T+t)+%7B+return(X%3CT%3E(5))%3B+%7D%0A%0Avoid+bar2()+%7B+=
foo(x(5))%3B+%7D'),l:'5',n:'1',o:'C%2B%2B+source+%231',t:'0')),k:50,l:'4',n=
:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:g62,filters:(b:'0',commen=
tOnly:'0',directives:'0',intel:'0'),options:'--std%3Dc%2B%2B14+-c'),l:'5',n=
:'0',o:'%231+with+x86-64+gcc+6.2',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0'))=
,l:'2',n:'0',o:'',t:'0')),version:4

On Tuesday, December 13, 2016 at 3:58:18 AM UTC-5, Dawid Pilarski wrote:
>
> It can be simple type like:
>
> //using new class template deduction
> template <typename T>
> class Value{
> public:
>     explicit Value(T value);
>     operator T (); //or simple T value() method
> private
> T storedValue;
> };
>
>
> same would be for Factor type.=20
> Purpuse of this class would be only for syntax sugaring function call, so
>
> round_up_multiple(2,3) // error, because constructor is explicit
> round_up_multiple(Value(2), Factor(3)); // fine=20
>
> also declaration of such a function will have to be templated, so
>
> template <typename T>
> T round_up_multiple(Value<T>, Factor<T>);
>
> 2016-12-12 16:23 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future=20
> Proposals <std-pr...@isocpp.org <javascript:>>:
>
>> I don't see how that would work.  Are Value and Factor concepts rather=
=20
>> than templates in your suggestion?  I only have a very rough idea of wha=
t's=20
>> in the Concepts TS.
>>
>> On Monday, December 12, 2016 at 3:51:08 AM UTC-5, Dawid Pilarski wrote:
>>>
>>> How about interface like this:
>>>
>>> Integral round_up_to_multiple(Value i, Factor factor);=20
>>>
>>> With both Value and Factor having explicit constructors.
>>> which should be called like this:
>>> round_up_to_multiple(Value(x), Factor(y));
>>>
>>> In fact there is no need here to introduce mround type. But I do not sa=
y=20
>>> it's bad here, although Value and Factor is IMO more expressive.
>>> It's still just an idea.
>>>
>>> On the other hand, It would be strange also to introduce double=20
>>> interface.=20
>>> First for / and * operators with just mround type and add and subtract=
=20
>>> with functions. It's inconsistent IMO, however I myself gave this=20
>>> suggestion. I think the API should be considered harder.
>>>
>>> 2016-12-10 22:40 GMT+01:00 'Walt Karas' via ISO C++ Standard - Future=
=20
>>> Proposals <std-pr...@isocpp.org>:
>>>
>>>> How about this alternative?
>>>>
>>>> #include <type_traits>
>>>>
>>>> template <typename I>
>>>> struct mround_type
>>>>   {
>>>>     static_assert(
>>>>       std::is_integral<I>::value, "mround_type requires integral type"=
);
>>>>
>>>>     const I value;
>>>>
>>>>     constexpr explicit mround_type(I v) : value(v) { }
>>>>
>>>>     // Rounded-up integral division.
>>>>     constexpr I div(I factor)
>>>>       {
>>>>         return((value + factor - 1) / factor);
>>>>       }
>>>>
>>>>     // Round up integer to multiple.
>>>>     constexpr I up(I factor)
>>>>       {
>>>>         return(div(factor) * factor);
>>>>       }
>>>>
>>>>     // Round down integer to multiple.
>>>>     constexpr I down(I factor)
>>>>       {
>>>>         return(value - (value % factor));
>>>>       }
>>>>   };
>>>>
>>>> template <typename I>
>>>> constexpr auto mround(I i)
>>>>   {
>>>>     static_assert(
>>>>       std::is_integral<I>::value,
>>>>       "mround() parameter must be of integral type");
>>>>
>>>>     return(mround_type<I>(i));
>>>>   }
>>>>
>>>> static_assert(mround(9).div(5) =3D=3D 2, "");
>>>> static_assert(mround(10).div(5) =3D=3D 2, "");
>>>> static_assert(mround(11).div(5) =3D=3D 3, "");
>>>>
>>>> static_assert(mround(9).up(5) =3D=3D 10, "");
>>>> static_assert(mround(10).up(5) =3D=3D 10, "");
>>>> static_assert(mround(11).up(5) =3D=3D 15, "");
>>>>
>>>> static_assert(mround(9).down(5) =3D=3D 5, "");
>>>> static_assert(mround(10).down(5) =3D=3D 10, "");
>>>> static_assert(mround(11).down(5) =3D=3D 10, "");
>>>>
>>>>
>>>>
>>>>
>>>> On Friday, December 9, 2016 at 11:30:40 AM UTC-5, Walt Karas wrote:
>>>>
>>>>> I take your point, it has validity.  But=20
>>>>> round_up_to_multiple(Integral, Integral) has issues for people like m=
e who=20
>>>>> don't have good memories.  Specifically, having two parameters of the=
 same=20
>>>>> type (that are not commutative).  I would likely be constantly lookin=
g up=20
>>>>> the right parameter order.  And if I ddin't look it up and got it wro=
ng,=20
>>>>> that would be a run-time bug, potentially one that was very hard to f=
ind.
>>>>>
>>>>> On Friday, December 9, 2016 at 4:21:28 AM UTC-5, Dawid Pilarski wrote=
:
>>>>>>
>>>>>> I do not quite like the idea of operator + and operator -. It's kind=
=20
>>>>>> of misleading, that operator + and - has so strange meaning. Why not=
 doing=20
>>>>>> just simple function round_up_to_multiple, which would have cleaner=
=20
>>>>>> interface?
>>>>>>
>>>>>>
>>>>>> 2016-12-08 19:39 GMT+01:00 'Walt Karas' via ISO C++ Standard - Futur=
e=20
>>>>>> Proposals <std-pr...@isocpp.org>:
>>>>>>
>>>>>>> #include <type_traits>
>>>>>>>
>>>>>>>
>>>>>>> template <typename I>
>>>>>>> struct mround_type
>>>>>>>   {
>>>>>>>     static_assert(
>>>>>>>       std::is_integral<I>::value, "mround_type requires integral=20
>>>>>>> type");
>>>>>>>
>>>>>>>
>>>>>>>     const I value;
>>>>>>>
>>>>>>>
>>>>>>>     constexpr explicit mround_type(I v) : value(v) { }
>>>>>>>   };
>>>>>>>
>>>>>>>
>>>>>>> template <typename I>
>>>>>>> constexpr auto mround(I i)
>>>>>>>   {
>>>>>>>     static_assert(
>>>>>>>       std::is_integral<I>::value,
>>>>>>>       "mround() parameter must be of integral type");
>>>>>>>
>>>>>>>
>>>>>>>     return(mround_type<I>(i));
>>>>>>>   }
>>>>>>>
>>>>>>>
>>>>>>> // Rounded-up integral division.
>>>>>>> template <typename I>
>>>>>>> constexpr I operator / (I i, mround_type<I> factor)
>>>>>>>   {
>>>>>>>     return((i + factor.value - 1) / factor.value);
>>>>>>>   }
>>>>>>>
>>>>>>>
>>>>>>> // Round up integer to multiple.
>>>>>>> template <typename I>
>>>>>>> constexpr I operator + (I i, mround_type<I> factor)
>>>>>>>   {
>>>>>>>     return((i / factor) * factor.value);
>>>>>>>   }
>>>>>>>
>>>>>>>
>>>>>>> // Round down integer to multiple.
>>>>>>> template <typename I>
>>>>>>> constexpr I operator - (I i, mround_type<I> factor)
>>>>>>>   {
>>>>>>>     return(i - (i % factor.value));
>>>>>>>   }
>>>>>>>
>>>>>>>
>>>>>>> static_assert(9 / mround(5) =3D=3D 2, "");
>>>>>>> static_assert(10 / mround(5) =3D=3D 2, "");
>>>>>>> static_assert(11 / mround(5) =3D=3D 3, "");
>>>>>>>
>>>>>>>
>>>>>>> static_assert(9 + mround(5) =3D=3D 10, "");
>>>>>>> static_assert(10 + mround(5) =3D=3D 10, "");
>>>>>>> static_assert(11 + mround(5) =3D=3D 15, "");
>>>>>>>
>>>>>>>
>>>>>>> static_assert(9 - mround(5) =3D=3D 5, "");
>>>>>>> static_assert(10 - mround(5) =3D=3D 10, "");
>>>>>>> static_assert(11 - mround(5) =3D=3D 10, "");
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --=20
>>>>>>> You received this message because you are subscribed to the Google=
=20
>>>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,=
=20
>>>>>>> send an email to std-proposal...@isocpp.org.
>>>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>>>> To view this discussion on the web visit=20
>>>>>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af197=
bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org=20
>>>>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1af19=
7bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium=3Demail&utm_source=
=3Dfooter>
>>>>>>> .
>>>>>>>
>>>>>>
>>>>>> --=20
>>>> You received this message because you are subscribed to the Google=20
>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send=
=20
>>>> an email to std-proposal...@isocpp.org.
>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>> To view this discussion on the web visit=20
>>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5b05d62b-=
b1ff-42f5-a929-e35d697c4869%40isocpp.org=20
>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5b05d62b=
-b1ff-42f5-a929-e35d697c4869%40isocpp.org?utm_medium=3Demail&utm_source=3Df=
ooter>
>>>> .
>>>>
>>>
>>> --=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit=20
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/be7fb134-ef=
a2-4f35-aa0f-51b11efc52da%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/be7fb134-e=
fa2-4f35-aa0f-51b11efc52da%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>
>

--=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/bebe2e54-c1b0-4460-87b0-1e97cc3b499e%40isocpp.or=
g.

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

<div dir=3D"ltr">Can you give a compiling example?<div><br></div><div>It se=
ems to me that my helper function template in indispensible:</div><div><br>=
</div><div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 2=
50, 250); border-color: rgb(187, 187, 187); border-style: solid; border-wid=
th: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"=
subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">t=
emplate</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> X<br></span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">explicit</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> X</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T t</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br><br><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">void=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> foo</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">X</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> x</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 bar</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</sp=
an><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"> foo</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">X</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">5</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: #660;" class=3D"styled-by-prettify">}</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">// causes an error</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">template</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>X</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">T 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: #660;" cla=
ss=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">return</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">X</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span><span style=3D"c=
olor: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">));</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br><br><br></span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> bar2</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: #660;" class=3D"styled-by-prettify">{</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> foo</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">x</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">5</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">));</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></=
div></code></div><div><br></div><div>Link to Compiler Explorer:</div><div><=
br></div><div>https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,optio=
ns:(colouriseAsm:&#39;0&#39;,compileOnChange:&#39;0&#39;),source:&#39;templ=
ate+%3Ctypename+T%3E%0Astruct+X%0A%7B+explicit+X(T+t)%3B+%7D%3B%0A%0Atempla=
te+%3Ctypename+T%3E%0Avoid+foo(X%3CT%3E+x)%3B%0A%0Avoid+bar()+%7B+foo(X(5))=
%3B+%7D%0A%0Atemplate+%3Ctypename+T%3E%0AX%3CT%3E+x(T+t)+%7B+return(X%3CT%3=
E(5))%3B+%7D%0A%0Avoid+bar2()+%7B+foo(x(5))%3B+%7D&#39;),l:&#39;5&#39;,n:&#=
39;1&#39;,o:&#39;C%2B%2B+source+%231&#39;,t:&#39;0&#39;)),k:50,l:&#39;4&#39=
;,n:&#39;0&#39;,o:&#39;&#39;,s:0,t:&#39;0&#39;),(g:!((h:compiler,i:(compile=
r:g62,filters:(b:&#39;0&#39;,commentOnly:&#39;0&#39;,directives:&#39;0&#39;=
,intel:&#39;0&#39;),options:&#39;--std%3Dc%2B%2B14+-c&#39;),l:&#39;5&#39;,n=
:&#39;0&#39;,o:&#39;%231+with+x86-64+gcc+6.2&#39;,t:&#39;0&#39;)),k:50,l:&#=
39;4&#39;,n:&#39;0&#39;,o:&#39;&#39;,s:0,t:&#39;0&#39;)),l:&#39;2&#39;,n:&#=
39;0&#39;,o:&#39;&#39;,t:&#39;0&#39;)),version:4<br></div><div><br></div>On=
 Tuesday, December 13, 2016 at 3:58:18 AM UTC-5, Dawid Pilarski wrote:<bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-l=
eft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div><div><di=
v><div>It can be simple type like:<br><br></div><div>//using new class temp=
late deduction<br></div>template &lt;typename T&gt;<br></div>class Value{<b=
r></div>public:<br></div>=C2=A0=C2=A0=C2=A0 explicit Value(T value);<br></d=
iv><div>=C2=A0=C2=A0=C2=A0 operator T (); //or simple T value() method<br><=
/div><div>private<br></div>T storedValue;<br><div><div><div><div>};<br><br>=
<br></div><div>same would be for Factor type. <br></div><div>Purpuse of thi=
s class would be only for syntax sugaring function call, so<br><br></div><d=
iv>round_up_multiple(2,3) // error, because constructor is explicit<br></di=
v><div>round_up_multiple(Value(2), Factor(3)); // fine <br><br></div><div>a=
lso declaration of such a function will have to be templated, so<br><br></d=
iv><div>template &lt;typename T&gt;<br></div><div>T round_up_multiple(Value=
&lt;T&gt;, Factor&lt;T&gt;);<br></div></div></div></div></div><div><br><div=
 class=3D"gmail_quote">2016-12-12 16:23 GMT+01:00 &#39;Walt Karas&#39; via =
ISO C++ Standard - Future Proposals <span dir=3D"ltr">&lt;<a href=3D"javasc=
ript:" target=3D"_blank" gdf-obfuscated-mailto=3D"6rReua1qCQAJ" rel=3D"nofo=
llow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onclic=
k=3D"this.href=3D&#39;javascript:&#39;;return true;">std-pr...@isocpp.org</=
a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I don&#39=
;t see how that would work.=C2=A0 Are Value and Factor concepts rather than=
 templates in your suggestion?=C2=A0 I only have a very rough idea of what&=
#39;s in the Concepts TS.<div><span><br>On Monday, December 12, 2016 at 3:5=
1:08 AM UTC-5, Dawid Pilarski wrote:</span><blockquote class=3D"gmail_quote=
" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><span><div dir=3D"ltr"><div><div><div>How about interface like this=
:<br><br>Integral round_up_to_multiple(Value i, Factor factor); <br><br></d=
iv><div>With both Value and Factor having explicit constructors.<br></div>w=
hich should be called like this:<br>round_up_to_multiple(Value(x), Factor(y=
));<br><br></div>In fact there is no need here to introduce mround type. Bu=
t I do not say it&#39;s bad here, although Value and Factor is IMO more exp=
ressive.<br></div><div>It&#39;s still just an idea.<br><br></div><div>On th=
e other hand, It would be strange also to introduce double interface. <br><=
/div><div>First for / and * operators with just mround type and add and sub=
tract with functions. It&#39;s inconsistent IMO, however I myself gave this=
 suggestion. I think the API should be considered harder.<br></div></div></=
span><div><br><div class=3D"gmail_quote"><div><div>2016-12-10 22:40 GMT+01:=
00 &#39;Walt Karas&#39; via ISO C++ Standard - Future Proposals <span dir=
=3D"ltr">&lt;<a rel=3D"nofollow">std-pr...@isocpp.org</a>&gt;</span>:<br></=
div></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bord=
er-left:1px #ccc solid;padding-left:1ex"><div><div><div dir=3D"ltr">How abo=
ut this alternative?<div><br></div><div><div style=3D"background-color:rgb(=
250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:=
1px;word-wrap:break-word"><code><div><span><div><font color=3D"#660066">#in=
clude &lt;type_traits&gt;</font></div><div><font color=3D"#660066"><br></fo=
nt></div><div><font color=3D"#660066">template &lt;typename I&gt;</font></d=
iv><div><font color=3D"#660066">struct mround_type</font></div><div><font c=
olor=3D"#660066">=C2=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =
=C2=A0 static_assert(</font></div><div><font color=3D"#660066">=C2=A0 =C2=
=A0 =C2=A0 std::is_integral&lt;I&gt;::value, &quot;mround_type requires int=
egral type&quot;);</font></div><div><font color=3D"#660066"><br></font></di=
v><div><font color=3D"#660066">=C2=A0 =C2=A0 const I value;</font></div><di=
v><font color=3D"#660066"><br></font></div><div><font color=3D"#660066">=C2=
=A0 =C2=A0 constexpr explicit mround_type(I v) : value(v) { }</font></div><=
div><font color=3D"#660066"><br></font></div></span><div><font color=3D"#66=
0066">=C2=A0 =C2=A0 // Rounded-up integral division.</font></div><div><font=
 color=3D"#660066">=C2=A0 =C2=A0 constexpr I div(I factor)</font></div><div=
><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 {</font></div><div><font colo=
r=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return((value + factor - 1) / fac=
tor);</font></div><span><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 }=
</font></div><div><font color=3D"#660066"><br></font></div><div><font color=
=3D"#660066">=C2=A0 =C2=A0 // Round up integer to multiple.</font></div></s=
pan><div><font color=3D"#660066">=C2=A0 =C2=A0 constexpr I up(I factor)</fo=
nt></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 {</font></div><d=
iv><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return(div(factor) *=
 factor);</font></div><span><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=
=A0 }</font></div><div><font color=3D"#660066"><br></font></div><div><font =
color=3D"#660066">=C2=A0 =C2=A0 // Round down integer to multiple.</font></=
div></span><div><font color=3D"#660066">=C2=A0 =C2=A0 constexpr I down(I fa=
ctor)</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 {</font=
></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return(valu=
e - (value % factor));</font></div><span><div><font color=3D"#660066">=C2=
=A0 =C2=A0 =C2=A0 }</font></div><div><font color=3D"#660066">=C2=A0 };</fon=
t></div><div><font color=3D"#660066"><br></font></div><div><font color=3D"#=
660066">template &lt;typename I&gt;</font></div><div><font color=3D"#660066=
">constexpr auto mround(I i)</font></div><div><font color=3D"#660066">=C2=
=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 static_assert(=
</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 std::is_inte=
gral&lt;I&gt;::value,</font></div><div><font color=3D"#660066">=C2=A0 =C2=
=A0 =C2=A0 &quot;mround() parameter must be of integral type&quot;);</font>=
</div><div><font color=3D"#660066"><br></font></div><div><font color=3D"#66=
0066">=C2=A0 =C2=A0 return(mround_type&lt;I&gt;(i));</font></div><div><font=
 color=3D"#660066">=C2=A0 }</font></div><div><font color=3D"#660066"><br></=
font></div></span><div><font color=3D"#660066">static_assert(mround(9).div(=
5) =3D=3D 2, &quot;&quot;);</font></div><div><font color=3D"#660066">static=
_assert(mround(10).div(<wbr>5) =3D=3D 2, &quot;&quot;);</font></div><div><f=
ont color=3D"#660066">static_assert(mround(11).div(<wbr>5) =3D=3D 3, &quot;=
&quot;);</font></div><div><font color=3D"#660066"><br></font></div><div><fo=
nt color=3D"#660066">static_assert(mround(9).up(5) =3D=3D 10, &quot;&quot;)=
;</font></div><div><font color=3D"#660066">static_assert(mround(10).up(5) =
=3D=3D 10, &quot;&quot;);</font></div><div><font color=3D"#660066">static_a=
ssert(mround(11).up(5) =3D=3D 15, &quot;&quot;);</font></div><div><font col=
or=3D"#660066"><br></font></div><div><font color=3D"#660066">static_assert(=
mround(9).down(<wbr>5) =3D=3D 5, &quot;&quot;);</font></div><div><font colo=
r=3D"#660066">static_assert(mround(10).down(<wbr>5) =3D=3D 10, &quot;&quot;=
);</font></div><div><font color=3D"#660066">static_assert(mround(11).down(<=
wbr>5) =3D=3D 10, &quot;&quot;);</font></div><div><br></div></div></code></=
div><span><br><br><br>On Friday, December 9, 2016 at 11:30:40 AM UTC-5, Wal=
t Karas wrote:</span><div><div><blockquote class=3D"gmail_quote" style=3D"m=
argin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div=
 dir=3D"ltr">I take your point, it has validity.=C2=A0 But round_up_to_mult=
iple(Integral, Integral) has issues for people like me who don&#39;t have g=
ood memories.=C2=A0 Specifically, having two parameters of the same type (t=
hat are not commutative).=C2=A0 I would likely be constantly looking up the=
 right parameter order.=C2=A0 And if I ddin&#39;t look it up and got it wro=
ng, that would be a run-time bug, potentially one that was very hard to fin=
d.<br><br>On Friday, December 9, 2016 at 4:21:28 AM UTC-5, Dawid Pilarski w=
rote:<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"><code>I do no=
t quite like the idea of operator + and operator -. It&#39;s kind of mislea=
ding, that operator + and - has so strange meaning. Why not doing just simp=
le function round_up_to_multiple, which would have cleaner interface?</code=
><code><span style=3D"color:rgb(0,0,0)"><br><br></span></code></div><div><b=
r><div class=3D"gmail_quote">2016-12-08 19:39 GMT+01:00 &#39;Walt Karas&#39=
; via ISO C++ Standard - Future Proposals <span dir=3D"ltr">&lt;<a rel=3D"n=
ofollow">std-pr...@isocpp.org</a>&gt;</span>:<br><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr"><div style=3D"background-color:rgb(250,250,250);borde=
r-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:brea=
k-word"><code><div><span style=3D"color:#800">#include</span><span style=3D=
"color:#000"> </span><span style=3D"color:#080">&lt;type_traits&gt;</span><=
span style=3D"color:#000"><br><br><br></span><span style=3D"color:#008">tem=
plate</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&=
lt;</span><span style=3D"color:#008">typename</span><span style=3D"color:#0=
00"> I</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#00=
0"><br></span><span style=3D"color:#008">struct</span><span style=3D"color:=
#000"> mround_type<br>=C2=A0 </span><span style=3D"color:#660">{</span><spa=
n style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">=
static_assert</span><span style=3D"color:#660">(</span><span style=3D"color=
:#000"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</sp=
an><span style=3D"color:#000">is_integral</span><span style=3D"color:#660">=
&lt;</span><span style=3D"color:#000">I</span><span style=3D"color:#660">&g=
t;::</span><span style=3D"color:#000">value</span><span style=3D"color:#660=
">,</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&qu=
ot;mround_type requires integral type&quot;</span><span style=3D"color:#660=
">);</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><spa=
n style=3D"color:#008">const</span><span style=3D"color:#000"> I value</spa=
n><span style=3D"color:#660">;</span><span style=3D"color:#000"><br><br><br=
>=C2=A0 =C2=A0 </span><span style=3D"color:#008">constexpr</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#008">explicit</span><span st=
yle=3D"color:#000"> mround_type</span><span style=3D"color:#660">(</span><s=
pan style=3D"color:#000">I v</span><span style=3D"color:#660">)</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#660">:</span><span styl=
e=3D"color:#000"> value</span><span style=3D"color:#660">(</span><span styl=
e=3D"color:#000">v</span><span style=3D"color:#660">)</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660">{</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">}</span><span style=3D"color:#000=
"><br>=C2=A0 </span><span style=3D"color:#660">};</span><span style=3D"colo=
r:#000"><br><br><br></span><span style=3D"color:#008">template</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span st=
yle=3D"color:#008">typename</span><span style=3D"color:#000"> I</span><span=
 style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#008">constexpr</span><span style=3D"color:#000"> </span><=
span style=3D"color:#008">auto</span><span style=3D"color:#000"> mround</sp=
an><span style=3D"color:#660">(</span><span style=3D"color:#000">I i</span>=
<span style=3D"color:#660">)</span><span style=3D"color:#000"><br>=C2=A0 </=
span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color:#008">static_assert</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=
=A0 std</span><span style=3D"color:#660">::</span><span style=3D"color:#000=
">is_integral</span><span style=3D"color:#660">&lt;</span><span style=3D"co=
lor:#000">I</span><span style=3D"color:#660">&gt;::</span><span style=3D"co=
lor:#000">value</span><span style=3D"color:#660">,</span><span style=3D"col=
or:#000"><br>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#080">&quot;m=
round() parameter must be of integral type&quot;</span><span style=3D"color=
:#660">);</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span=
><span style=3D"color:#008">return</span><span style=3D"color:#660">(</span=
><span style=3D"color:#000">mround_type</span><span style=3D"color:#660">&l=
t;</span><span style=3D"color:#000">I</span><span style=3D"color:#660">&gt;=
(</span><span style=3D"color:#000">i</span><span style=3D"color:#660">));</=
span><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660=
">}</span><span style=3D"color:#000"><br><br><br></span><span style=3D"colo=
r:#800">// Rounded-up integral division.</span><span style=3D"color:#000"><=
br></span><span style=3D"color:#008">template</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#660">&lt;</span><span style=3D"color:#008=
">typename</span><span style=3D"color:#000"> I</span><span style=3D"color:#=
660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"color:=
#008">constexpr</span><span style=3D"color:#000"> I </span><span style=3D"c=
olor:#008">operator</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">/</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#660">(</span><span style=3D"color:#000">I i</span><span style=3D"color:#=
660">,</span><span style=3D"color:#000"> mround_type</span><span style=3D"c=
olor:#660">&lt;</span><span style=3D"color:#000">I</span><span style=3D"col=
or:#660">&gt;</span><span style=3D"color:#000"> factor</span><span style=3D=
"color:#660">)</span><span style=3D"color:#000"><br>=C2=A0 </span><span sty=
le=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color:#008">return</span><span style=3D"color:#660">((</s=
pan><span style=3D"color:#000">i </span><span style=3D"color:#660">+</span>=
<span style=3D"color:#000"> factor</span><span style=3D"color:#660">.</span=
><span style=3D"color:#000">value </span><span style=3D"color:#660">-</span=
><span style=3D"color:#000"> </span><span style=3D"color:#066">1</span><spa=
n style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">/</span><span style=3D"color:#000"> factor</span><span st=
yle=3D"color:#660">.</span><span style=3D"color:#000">value</span><span sty=
le=3D"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 </span><sp=
an style=3D"color:#660">}</span><span style=3D"color:#000"><br><br><br></sp=
an><span style=3D"color:#800">// Round up integer to multiple.</span><span =
style=3D"color:#000"><br></span><span style=3D"color:#008">template</span><=
span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><sp=
an style=3D"color:#008">typename</span><span style=3D"color:#000"> I</span>=
<span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#008">constexpr</span><span style=3D"color:#000"> I <=
/span><span style=3D"color:#008">operator</span><span style=3D"color:#000">=
 </span><span style=3D"color:#660">+</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">(</span><span style=3D"color:#000">I i</span>=
<span style=3D"color:#660">,</span><span style=3D"color:#000"> mround_type<=
/span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</s=
pan><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"> facto=
r</span><span style=3D"color:#660">)</span><span style=3D"color:#000"><br>=
=C2=A0 </span><span style=3D"color:#660">{</span><span style=3D"color:#000"=
><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span sty=
le=3D"color:#660">((</span><span style=3D"color:#000">i </span><span style=
=3D"color:#660">/</span><span style=3D"color:#000"> factor</span><span styl=
e=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">*</span><span style=3D"color:#000"> factor</span><span style=3D=
"color:#660">.</span><span style=3D"color:#000">value</span><span style=3D"=
color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 </span><span sty=
le=3D"color:#660">}</span><span style=3D"color:#000"><br><br><br></span><sp=
an style=3D"color:#800">// Round down integer to multiple.</span><span styl=
e=3D"color:#000"><br></span><span style=3D"color:#008">template</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span s=
tyle=3D"color:#008">typename</span><span style=3D"color:#000"> I</span><spa=
n style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><sp=
an style=3D"color:#008">constexpr</span><span style=3D"color:#000"> I </spa=
n><span style=3D"color:#008">operator</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">-</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">(</span><span style=3D"color:#000">I i</span><spa=
n style=3D"color:#660">,</span><span style=3D"color:#000"> mround_type</spa=
n><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">I</span>=
<span style=3D"color:#660">&gt;</span><span style=3D"color:#000"> factor</s=
pan><span style=3D"color:#660">)</span><span style=3D"color:#000"><br>=C2=
=A0 </span><span style=3D"color:#660">{</span><span style=3D"color:#000"><b=
r>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span style=
=3D"color:#660">(</span><span style=3D"color:#000">i </span><span style=3D"=
color:#660">-</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">(</span><span style=3D"color:#000">i </span><span style=3D"color:#66=
0">%</span><span style=3D"color:#000"> factor</span><span style=3D"color:#6=
60">.</span><span style=3D"color:#000">value</span><span style=3D"color:#66=
0">));</span><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"co=
lor:#660">}</span><span style=3D"color:#000"><br><br><br></span><span style=
=3D"color:#008">static_assert</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#066">9</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">/</span><span style=3D"color:#000"> mround</span><span st=
yle=3D"color:#660">(</span><span style=3D"color:#066">5</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#066">2</span><span style=3D"color:#660">,</span><span style=3D"color:=
#000"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"=
color:#660">);</span><span style=3D"color:#000"><br></span><span style=3D"c=
olor:#008">static_assert</span><span style=3D"color:#660">(</span><span sty=
le=3D"color:#066">10</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">/</span><span style=3D"color:#000"> mround</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#066">5</span><span style=3D"=
color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color=
:#066">2</span><span style=3D"color:#660">,</span><span style=3D"color:#000=
"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"colo=
r:#660">);</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#008">static_assert</span><span style=3D"color:#660">(</span><span style=
=3D"color:#066">11</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">/</span><span style=3D"color:#000"> mround</span><span style=3D=
"color:#660">(</span><span style=3D"color:#066">5</span><span style=3D"colo=
r:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#06=
6">3</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#6=
60">);</span><span style=3D"color:#000"><br><br><br></span><span style=3D"c=
olor:#008">static_assert</span><span style=3D"color:#660">(</span><span sty=
le=3D"color:#066">9</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">+</span><span style=3D"color:#000"> mround</span><span style=
=3D"color:#660">(</span><span style=3D"color:#066">5</span><span style=3D"c=
olor:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:=
#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color:=
#066">10</span><span style=3D"color:#660">,</span><span style=3D"color:#000=
"> </span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"colo=
r:#660">);</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#008">static_assert</span><span style=3D"color:#660">(</span><span style=
=3D"color:#066">10</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">+</span><span style=3D"color:#000"> mround</span><span style=3D=
"color:#660">(</span><span style=3D"color:#066">5</span><span style=3D"colo=
r:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#06=
6">10</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> =
</span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#=
660">);</span><span style=3D"color:#000"><br></span><span style=3D"color:#0=
08">static_assert</span><span style=3D"color:#660">(</span><span style=3D"c=
olor:#066">11</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">+</span><span style=3D"color:#000"> mround</span><span style=3D"colo=
r:#660">(</span><span style=3D"color:#066">5</span><span style=3D"color:#66=
0">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#066">=
15</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#660=
">);</span><span style=3D"color:#000"><br><br><br></span><span style=3D"col=
or:#008">static_assert</span><span style=3D"color:#660">(</span><span style=
=3D"color:#066">9</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">-</span><span style=3D"color:#000"> mround</span><span style=3D"=
color:#660">(</span><span style=3D"color:#066">5</span><span style=3D"color=
:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660=
">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#066=
">5</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </=
span><span style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#66=
0">);</span><span style=3D"color:#000"><br></span><span style=3D"color:#008=
">static_assert</span><span style=3D"color:#660">(</span><span style=3D"col=
or:#066">10</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">-</span><span style=3D"color:#000"> mround</span><span style=3D"color:=
#660">(</span><span style=3D"color:#066">5</span><span style=3D"color:#660"=
>)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D=
=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#066">10<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span=
><span style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#660">)=
;</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">st=
atic_assert</span><span style=3D"color:#660">(</span><span style=3D"color:#=
066">11</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
>-</span><span style=3D"color:#000"> mround</span><span style=3D"color:#660=
">(</span><span style=3D"color:#066">5</span><span style=3D"color:#660">)</=
span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D</=
span><span style=3D"color:#000"> </span><span style=3D"color:#066">10</span=
><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#080">&quot;&quot;</span><span style=3D"color:#660">);</sp=
an><span><font color=3D"#888888"><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#000"><br></span></font></span></div></code></div><span><f=
ont color=3D"#888888"><div><br><br></div></font></span></div><span><font co=
lor=3D"#888888">

<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 rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</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/1af197bf-4e85-4e4b-9486-dd7ca150c139%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/1af197bf-4e85-4e4b-9486-dd7ca150c139%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/1af197bf-4e85-4e4b-<wbr>9486-=
dd7ca150c139%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br></div>
</blockquote></div></blockquote></div></div></div></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 rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</a>.<br></div></div></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/5b05d62b-b1ff-42f5-a929-e35d697c4869%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/5b05d62b-b1ff-42f5-<wbr>a929-=
e35d697c4869%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div>
</blockquote></div></div><span>

<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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
6rReua1qCQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"6rReua1qCQAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/be7fb134-efa2-4f35-aa0f-51b11efc52da%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/be7fb134-efa2-4f35-aa0f-51b11efc52da%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/be7fb134-efa2-4f35-aa0f-51b11efc52da%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/be7fb134-efa2-4f35-<wbr>aa0f-=
51b11efc52da%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div>
</blockquote></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/bebe2e54-c1b0-4460-87b0-1e97cc3b499e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/bebe2e54-c1b0-4460-87b0-1e97cc3b499e=
%40isocpp.org</a>.<br />

------=_Part_1817_453921513.1481643867273--

------=_Part_1816_2111119432.1481643867271--

.