Topic: Making base classes easier to define
Author: stackmachine@hotmail.com
Date: Sun, 11 Nov 2012 14:45:16 -0800 (PST)
Raw View
------=_Part_1420_32568618.1352673916501
Content-Type: text/plain; charset=ISO-8859-1
Hi,
Defining baseclasses has always been annoying, if you want to make sure
they have the right semantics. (noncopyable, polymoprhic, ...) To make this
a bit easier, I propose adding 2 new contextual keywords, namely
static_base and polymorphic_base.
These keywords can be used at the same place of the final-specifier.
static_base is intended to be used for helper-classes. static_base makes
all default-generated operators (constructors, assignment operators, dtor)
protected. CRTP bases would be an example, where this keyword could be used.
polymorphic_base is similar to static_base, but unlike static_base, it
makes the dtor public virtual. As the name suggests, this keyword should be
used for polymophic base classes.
A class can either be final, static_base, or polymorphic_base, but not 2 or
more of them.
Why this has to be a language feature: You can't make a classes operations
protected by inheriting from a baseclass. It is possible to achieve the
same behaviour with macros, but they have their own problems.
--
------=_Part_1420_32568618.1352673916501
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,<br><br>Defining baseclasses has always been annoying, if you want to ma=
ke sure they have the right semantics. (noncopyable, polymoprhic, ...) To m=
ake this a bit easier, I propose adding 2 new contextual keywords, namely s=
tatic_base and polymorphic_base.<br>These keywords can be used at the same =
place of the final-specifier. static_base is intended to be used for helper=
-classes. static_base makes all default-generated operators (constructors, =
assignment operators, dtor) protected. CRTP bases would be an example, wher=
e this keyword could be used.<br>polymorphic_base is similar to static_base=
, but unlike static_base, it makes the dtor public virtual. As the name sug=
gests, this keyword should be used for polymophic base classes.<br>A class =
can either be final, static_base, or polymorphic_base, but not 2 or more of=
them.<br><br>Why this has to be a language feature: You can't make a class=
es operations protected by inheriting from a baseclass. It is possible to a=
chieve the same behaviour with macros, but they have their own problems.<br=
>
<p></p>
-- <br />
<br />
<br />
<br />
------=_Part_1420_32568618.1352673916501--
.