Classes that models the Final
concept satisfy the
following expressions:
Let B
a base class of Final
, b
an instance of B
, bc
an instance of
B const
.

Final::final(&am=
p;b)=
return the Final&=
;
reference associated to b
.

Final::final(&am=
p;bc)
returns the const Fin=
al&
reference associated
to bc
.
Classes that models the FinalUnderlying
concept
satisfy the following expressions:
Let B
a base class of Final
, b
an instance of B
, bc
an instance of B const
,
f
an instace of Final
and fc
and instance of `Final const '.

Final::underlying_type
the
underlying type.

Final::underlying(&b)=
return a reference to Final::underlying_type&
associated to b.

Final::underlying(&bc)
return a constant reference to Final::underlying_type const&
associated to bc
.

f.=
underlying()
return a reference to Final::underlying_type&
associated to f.

fc.underlying()
return a constant reference to Final::underlying_type const&
associated to fc
.
A Mixin is a template class having two template parameters, the
Final type and the Base type.
The archetype of a Mixin is
template <=
span class=3D"special"><typename <=
span class=3D"identifier">Final, typename Base<=
span class=3D"special">>
struct MixinArche=
type : Bas=
e
{
...
};
A MetaMixin is a metafunction having as nested type a Mixin.
The archetype of a MetaMixin is
struct MetaMixinArchetype {=
template <typename Fina=
l, typename Base>
struct type : Base
{
...
};
};
Associated to a type there is a metamixin that states the default
operations inherited (inherited_from_underlying). This metamixin is
a customization point and can be used=C2=A0 while defining a new type
based on a underlying type. We can define then a new strongly int
class as follows
=C2=A0=C2=A0=C2=A0 using GameScore =3D opaque::new_type< int, struct=
GameScoreTag,
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 opaque::derives< opaque::inher=
ited_from_underlying >
=C2=A0=C2=A0=C2=A0 >;
In addition to aliases we can define classes as e.g. the Energy from
p0109r0
class Energy : public opaque::new_class< Energy, double,
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0opaque::derive=
s<
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=
=C2=A0 opaque::using_additive,
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=
=C2=A0 opaque::using_multipliative_with<double>
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 >
> {
=C2=A0=C2=A0 =C2=A0using base_type =3D opaque::new_class< Energy, do=
uble,
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0opaque::derive=
s<
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=
=C2=A0 opaque::using_additive,
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=
=C2=A0 opaque::using_multipliative_with<double>
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 >;
public:
=C2=A0=C2=A0 =C2=A0using base_type::base::type;
=C2=A0=C2=A0=C2=A0 void print();
};
this will be the equivalent to the p0109r0 [2] opaque type
using energy =3D protected double {
=C2=A0=C2=A0=C2=A0 // additive/addable
=C2=A0=C2=A0=C2=A0 friend energy operator+ (energy) =3D default;
=C2=A0=C2=A0=C2=A0 friend energy operator+ (energy , energy) =3D defaul=
t;
=C2=A0=C2=A0=C2=A0 friend energy operator+=3D (energy& , energy) =
=3D default;
=C2=A0=C2=A0=C2=A0 // additive/
subtractable<=
/span>
=C2=A0=C2=A0=C2=A0 friend energy operator (energy) =3D default;
=C2=A0=C2=A0=C2=A0 friend energy operator (energy , energy) =3D defaul=
t;
=C2=A0=C2=A0=C2=A0 friend energy operator=3D (energy& , energy) =
=3D default;
=C2=A0=C2=A0=C2=A0 // multipliative_with<double>
=C2=A0=C2=A0=C2=A0 friend energy& operator*=3D(energy&, double)=
=3D default;
=C2=A0=C2=A0=C2=A0 friend energy operator* (energy , double) =3D defaul=
t;
=C2=A0=C2=A0=C2=A0 friend energy operator* (double , energy) =3D defaul=
t;
=C2=A0=C2=A0=C2=A0 friend energy& operator/=3D(energy&, double)=
=3D default;
=C2=A0=C2=A0=C2=A0 friend energy operator/ (energy , double) =3D defaul=
t;
=C2=A0=C2=A0=C2=A0 void print();
};
Having a way to name the base class will reduce the syntactic noise
class Energy : public using base_type =3D opaque::new_class<
Energy, double,
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0opaque::derive=
s<
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=
=C2=A0 opaque::using_additive,
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=
=C2=A0 opaque::using_multipliative_with<double>
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 >
> {
public:
=C2=A0=C2=A0 =C2=A0using base_type::base::type;
=C2=A0=C2=A0=C2=A0 void print();
};
Comments welcome,
Vicente
[0]
http://www.openstd.org/jtc1/sc22/w=
g21/docs/papers/2006/n2141.html
[1]
http://www.openstd.org/jtc1/sc22/=
wg21/docs/papers/2015/p0109r0.pdf

You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard  Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to stdproposa=
ls+unsubscribe@isocpp.org.
To post to this group, send email to stdproposals@isocpp.org.
To view this discussion on the web visit https://groups.google.=
com/a/isocpp.org/d/msgid/stdproposals/d2160ffcc6bf62122b9cb589b407ed50=
%40wanadoo.fr.
E4887C3B61908238FE6C1813
.