Topic: Reusing a class (or primitive type) with strong type
Author: galik.bool@gmail.com
Date: Sun, 24 Sep 2017 06:13:31 -0700 (PDT)
Raw View
------=_Part_4489_1522420550.1506258811731
Content-Type: multipart/alternative;
boundary="----=_Part_4490_1203879552.1506258811732"
------=_Part_4490_1203879552.1506258811732
Content-Type: text/plain; charset="UTF-8"
*Class Equivalents*
This document reads better in GitHub Markdown, there is a copy here:
https://github.com/galik/CppCoreGuidelines/blob/docs/ClassEquivalents.md
In order to increase the type safety of systems according to guidelines
like [I.4
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Ri-typed>]
from the [CppCoreGuidelines
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md>
].
Currently if we want to make a typename more meaningful to aid readability
we can us a type alias like so:
using redlist = std::vector<int>;
using bluelist = std::vector<int>;
However this does not provide any additional type safety. We can still use
a `std::vector<int>` wherever we ask for a `redlist` or a `bluelist` and,
indeed we can use `redlist` and `bluelist` interchangeably. Sometimes this
is exactly what we want. For example we sometimes make a type alias because
the actual type is too long and unwieldy but it is the actual type we wish
to accept. This is true of iterators, for example.
But other times we make type aliases to add meaning to the data the type
contains. It may behave semantically identical to a *vector* of integers
and yet require distinct treatment. We may want to avoid potential errors
that might occur by accidentally sending a `std::vector<int>` to a function
designed to process a `redlist`. We may want to protect ourselves from
allowing a function designed to process `redlist` objects from receiving
`bluelist` objects as a parameter.
using redlist = std::vector<int>;
using bluelist = std::vector<int>;
void process_reds(redlist const& reds)
{
}
void process_blues(bluelist const& blues)
{
}
// ...
redlist reds = get_latest_reds();
bluelist blues = get_old_blues();
process_reds(blues); // whoops error but compiler allows it
process_blues(reds); // whoops double dang but compiler allows it```
This proposal would make it possible to define `redlist` and `bluelist` as
*first class types* which share identical functionality with the type they
were defined equal to but exist as separate and distinct entries in the
compiler's type system.
The proposed syntax is to mirror the current `using` syntax when defining a
type alias. So instead of this:
using redlist = std::vector<int>;
using bluelist = std::vector<int>;
We can have this:
class redlist = std::vector<int>;
class bluelist = std::vector<int>;
One class becomes *wholly equal* to another class.
So whereas the *type alias* syntax reads "using typename redlist is equal
to using typename std::vector<int>", the proposed addition would read
"class redlist is defined equal to (the same as) class std::vector<int>".
It would literally be the same as redefining the entire class
`std::vector<int>` but using the name `redlist` instead of `vector`
(namespaces notwithstanding).
As this is a template class it would behave in all ways identical to the
template `std::vector<T>` with `T == int` except the compiler would enforce
type safety between `redlist`, `bluelist` and `vector<int>`. They could
even share the same generated code.
Being first class types means that Class Equivalents could be overloaded.
Whereas type aliases will cause an ambiguity here, Equivalent Classes will
overload as if they were defined independently of the type they are
equivalenced with.
void process(redlist const& reds)
{
}
// redfinition with type aliases but legal overload with Class Equivalents
void process(bluelist const& blues)
{
}
There would be a natural explicit conversion using `static_cast` as in:
redlist reds;
bluelist& blues = static_cast<bluelist&>(reds);
*Built in types*
It is also proposed that the concept be applied to built-in types too:
class disk_id = int;
This would introduce a *strongly typed* integer that behaved *identically*
to an actual *integer* except that it would *never* be convertible to an
`int` without an explicit cast.
So now it becomes safe to write:
void spin_down(disk_id id);
We can be sure no stray `int` will accidentally be sent to out disk
function. We would have, in effect, created a new built-in numerical type
that happens to behave identically to an `int` but that is
non-interchangeable with `int` (except by explicit cast).
--
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/09a8ff25-8a18-4b1a-a88b-4bda8294e039%40isocpp.org.
------=_Part_4490_1203879552.1506258811732
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><font size=3D"4"><b>Class Equivalents</b></font></div=
><div><br></div><div>This document reads better in GitHub Markdown, there i=
s a copy here:</div><div><br></div><div><a href=3D"https://github.com/galik=
/CppCoreGuidelines/blob/docs/ClassEquivalents.md">https://github.com/galik/=
CppCoreGuidelines/blob/docs/ClassEquivalents.md</a><br></div><div><br></div=
><div>In order to increase the type safety of systems according to guidelin=
es like [<a href=3D"https://github.com/isocpp/CppCoreGuidelines/blob/master=
/CppCoreGuidelines.md#Ri-typed">I.4</a>] from the [<a href=3D"https://githu=
b.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md">CppCoreGui=
delines</a>].</div><div><br></div><div>Currently if we want to make a typen=
ame more meaningful to aid readability we can us a type alias like so:</div=
><div><br></div><div class=3D"prettyprint" style=3D"background-color: rgb(2=
50, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; borde=
r-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div clas=
s=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">using</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
redlist </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">vector</span><span st=
yle=3D"color: #080;" class=3D"styled-by-prettify"><int></span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">using</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> bluelist </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">vector</span><span style=3D"color: #080;" class=3D"styled-by-pret=
tify"><int></span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span></div></code></div><div><br></div><div>However this does not provi=
de any additional type safety. We can still use a `std::vector<int>` =
wherever we ask for a `redlist` or a `bluelist` and, indeed we can use `red=
list` and `bluelist` interchangeably. Sometimes this is exactly what we wan=
t. For example we sometimes make a type alias because the actual type is to=
o long and unwieldy but it is the actual type we wish to accept. This is tr=
ue of iterators, for example.</div><div><br></div><div>But other times we m=
ake type aliases to add meaning to the data the type contains. It may behav=
e semantically identical to a *vector* of integers and yet require distinct=
treatment. We may want to avoid potential errors that might occur by accid=
entally sending a `std::vector<int>` to a function designed to proces=
s a `redlist`. We may want to protect ourselves from allowing a function de=
signed to process `redlist` objects from receiving `bluelist` objects as a =
parameter.=C2=A0</div><div><br></div><div class=3D"prettyprint" style=3D"ba=
ckground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); borde=
r-style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"p=
rettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">using</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> redlist </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ve=
ctor</span><span style=3D"color: #080;" class=3D"styled-by-prettify"><in=
t></span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> bluelist </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">vector</span><span style=3D"color: #080;" clas=
s=3D"styled-by-prettify"><int></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> process_reds</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">redlist </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>const</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> reds</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> process_blues</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">bluelist </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">const</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> blues</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// ...</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br>redlist reds </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> get_latest_reds</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>bluelist blues </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> get_old_blues</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br>process_reds</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">blues</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"s=
tyled-by-prettify">// whoops error but compiler allows it</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>process_blues</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">reds</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// whoops double dang but compiler allows it</span>=
<span style=3D"background-color: white; color: rgb(34, 34, 34); font-family=
: Arial, Helvetica, sans-serif;"><span style=3D"color: #800;" class=3D"styl=
ed-by-prettify">```</span></span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span></div></code></div><div><br></div><div><br></div=
><div>This proposal would make it possible to define `redlist` and `bluelis=
t` as *first class types* which share identical functionality with the type=
they were defined equal to but exist as separate and distinct entries in t=
he compiler's type system.</div><div><br></div><div>The proposed syntax=
is to mirror the current `using` syntax when defining a type alias. So ins=
tead of this:</div><div><br></div><div class=3D"prettyprint" style=3D"backg=
round-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-s=
tyle: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pret=
typrint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">using</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> redlist </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">vec=
tor</span><span style=3D"color: #080;" class=3D"styled-by-prettify"><int=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> bluelist </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">vector</span><span style=3D"color: #080;" class=
=3D"styled-by-prettify"><int></span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span></div></code></div><div><br></div><div>We can ha=
ve this:</div><div><br></div><div class=3D"prettyprint" 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 class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> redlist </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">vector</sp=
an><span style=3D"color: #080;" class=3D"styled-by-prettify"><int></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> bluelist </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">vector</span><span style=3D"color: #080;" class=3D"sty=
led-by-prettify"><int></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span></div></code></div><div><br><br></div><div>One class be=
comes *wholly equal* to another class.</div><div><br></div><div>So whereas =
the *type alias* syntax reads "using typename redlist is equal to usin=
g typename std::vector<int>", the proposed addition would read &=
quot;class redlist is defined equal to (the same as) class std::vector<i=
nt>". It would literally be the same as redefining the entire class=
`std::vector<int>` but using the name `redlist` instead of `vector` =
(namespaces notwithstanding).</div><div><br></div><div>As this is a templat=
e class it would behave in all ways identical to the template `std::vector&=
lt;T>` with `T =3D=3D int` except the compiler would enforce type safety=
between `redlist`, `bluelist` and `vector<int>`. They could even sha=
re the same generated code.</div><div><br></div><div>Being first class type=
s means that Class Equivalents could be overloaded. Whereas type aliases wi=
ll cause an ambiguity here, Equivalent Classes will overload as if they wer=
e defined independently of the type they are equivalenced with.</div><div><=
br></div><div class=3D"prettyprint" 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 class=3D"prettyprint"><div class=3D"su=
bprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">voi=
d</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> process<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">redlist </span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> reds</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br></span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br><br></span><span style=3D"color: #800;" class=3D"styled-by-prettify=
">// redfinition with type aliases but legal overload with Class Equivalent=
s </span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> process</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">bluelist </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> blues</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> <br></span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br><br></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span></div></code></div><div><br></div><div>There would be a natural expli=
cit conversion using `static_cast` as in:</div><div><br></div><div class=3D=
"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: =
rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: brea=
k-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">redlist reds</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>bluelist</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> blues </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">static_cast</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">bluelist</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&>(</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">reds</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span></div></code></div><div><br></div><div><b>Built in types</b><=
/div><div><br></div><div>It is also proposed that the concept be applied to=
built-in types too:</div><div><br></div><div class=3D"prettyprint" 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 clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> disk_id </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan></div></code></div><div><br></div><div>This would introduce a *strongly=
typed* integer that behaved *identically* to an actual *integer* except th=
at it would *never* be convertible to an `int` without an explicit cast.</d=
iv><div><br></div><div>So now it becomes safe to write:</div><div><br></div=
><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); =
border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; w=
ord-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyp=
rint"><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> spin_down</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">disk_id id</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><div=
><br></div><div>We can be sure no stray `int` will accidentally be sent to =
out disk function. We would have, in effect, created a new built-in numeric=
al type that happens to behave identically to an `int` but that is non-inte=
rchangeable with `int` (except by explicit cast).</div><div><br></div><div>=
<br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/09a8ff25-8a18-4b1a-a88b-4bda8294e039%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/09a8ff25-8a18-4b1a-a88b-4bda8294e039=
%40isocpp.org</a>.<br />
------=_Part_4490_1203879552.1506258811732--
------=_Part_4489_1522420550.1506258811731--
.