
Positive: The macro lets guarantee that a class is final. For example, there is a "textbook" error of deleting an object of derived class whose base class have non-virtual destructor. The error, resulting in splitting, manifests in run time and is hard to diagnose. The usual way to avoid the error is to declare almost all classes with virtual destructor, even when it is not needed. The macro provides a better alternative. Negative: An example: a point on a screen. In a graphic application it can be represented by a structure of two unsigned int, x and y. Can we make the structure final? The class nonderivable_helper contains a virtual function and a virtual destructor. Every class derived from nonderivable_helper also will contain virtual function and/or destructor. It follows that in typical implementation the final classes will contain a pointer to vtable, even if they have none virtual functions of their own (or none function at all). Technical: I tested a previous version with MinGW gcc 3.4.2 and with MSVC 8; the both worked as expected. Sincerely, Yura On 3/7/07, Manuel Fiorelli <manuel.fiorelli@gmail.com> wrote:
I wrote a library which implements the "non derivable" semantics, which is natively supported by some programming languages such as Java or C#. I believe it is mature for a submission and I request everybody for a feedback about the library itself. I could test it only witch GCC 4.1 but it seems to be 100% standard compliant.
I published the library in the Vault under the folder "Generic Programming" with the name "nonderivable.zip".
I know that in the vault there is a similar library (called "noninheritable") but one must consider that: 1) it uses a different idiom (private constructor and friend declaration) 2) it uses non standard features, while my implementation aims to be 100% standard compliant 3) it uses a different syntax 4) at least my request could increase the interest about that library
Usage -------/ Suppose you want to define a final class Foo, then you have to write
class Foo : BOOST_NON_DERIVABLE {
};
Best regards, Manuel Fiorelli _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost