boost::final similar to boost::noncopyable

Hi all, The question is why there is not a boost::final similar to boost::noncopyable? But first, let me tell you a little what I'm trying to achieve in my project and what drive me to look for a boost::final class. In my framework I have a class hierarchy for objects to be thrown. Base exception class is not abstract, so I can throw either base generalException or mathException (exception from math library) or whatever special kind of exception. To handle exception propagation from threads I decided to add clone and throw methods to all the exception classes and now, it looks like it makes sense to change generalException to declare abstract the clone and throw methods and to allow throw only of concrete classes of exceptions. So I got in the place where I need to block client libraries from defining hierarchy like: generalException >-- layerException >-- clientException where they skip defining clone/throw in classes like clientException. For this I was looking for a way to make classes like layerException "final", i.e. to disallow further inheritance from it, and comment out why I made it final. While looking for a suitable solution I checked the boost thinking that as there is the boos::noncopyable there must be also a boost::final or similar. I've been surprised not to find it but I search further and came across 3 versions presented in C++ FAQ LITE: http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.11 Using upper link I got to the following implementation hoping I will be able to create something like boos::noncopyable //implementation of final utility class class virt_final { public: virt_final(){} }; class final : public virtual virt_final { public: final(){} }; //using of final utility class class aFinalClass: private final { public: aFinalClass(){} }; /*Uncomment the following is issuing a compiler error class aClassThatShouldIssueCompileException: public aFinalClass { public: aClassThatShouldIssueCompileException(){} }; */ //testing a final class int main() { aFinalClass a; //works fine aFinalClass b(a); //error I can not understand return 0; } Evything was working perfect until I got to the aFinalClass b(a); where MSVC7/8 is unable to generate copy constructor for aFinalClass. Getting up to here I start realized why there is no boost::final available. But still I did not understand what is wrong with the code. Or is it a compiler problem? GCC compiles it nicely, so who is wrong? Are there any other "standard" ways known to disallow inheriting from the class except listed in the C++ FAQ LITE?

"Costin Calisov" <costin@moduleworks.com> wrote in message news:F258FCFE839645D79FA241A0CCAA8EC0@mwCostin...
Are there any other "standard" ways known to disallow inheriting from the class except listed in the C++ FAQ LITE?
AFAIK there is no standard compliant way to implement final. At least not until C++09. Gennadiy
participants (2)
-
Costin Calisov
-
Gennadiy Rozental