
Gennaro Prota wrote:
On Sun, 28 Mar 2004 12:55:10 +0200, "Pavel Vozenilek" <pavel_vozenilek@hotmail.com> wrote:
"Reece Dunn" <msclrhd@hotmail.com> wrote
So is it possible to prevent derivation? If not, then at least make it harder to do so (and put a warning in the docs)?
Yes.
Legal way: http://www.research.att.com/~bs/bs_faq2.html#no-derivation
And where is derivation prevented? ;) That only gives an error when you try instantiating the derived class. (Not only you may still derive, but of course you can access and use any static members).
There aren't any static members to errorcheck, so this is fine. If you try to do something like: class foobar: public boost::errorcheck<> { // ... }; you will not get any errors until you do something like: foobar foo; which generates an error message like: VC7.1 -- test.cpp(11) : error C2248: 'boost::detail::cannot_derive_errorcheck<Storage,MsgStorage>::__ctor' : cannot access private member declared in class 'boost::detail::cannot_derive_errorcheck<Storage,MsgStorage>' with [ Storage=boost::policy::error_storage<>, MsgStorage=boost::policy::no_errormsg_storage ] and [ Storage=boost::policy::error_storage<>, MsgStorage=boost::policy::no_errormsg_storage ] and [ Storage=boost::policy::error_storage<>, MsgStorage=boost::policy::no_errormsg_storage ] d:\devel\ADL++\include\boost\errorcheck.hpp(102) : see declaration of 'boost::detail::cannot_derive_errorcheck<Storage,MsgStorage>::__ctor' with [ Storage=boost::policy::error_storage<>, MsgStorage=boost::policy::no_errormsg_storage ] and [ Storage=boost::policy::error_storage<>, MsgStorage=boost::policy::no_errormsg_storage ] VC6 -- test.cpp(70) : error C2248: 'cannot_derive_errorcheck<class boost::policy::error_storage<int>,class boost::policy::no_errormsg_storage>::cannot_derive_errorcheck<class boost::policy::error_storage<int>,class boost::policy::no_errormsg_storage>' : cannot access private member declared in class 'boost::detail::cannot_derive_errorcheck<class boost::policy::error_storage<int>,class boost::policy::no_errormsg_storage>' Borland C++5.5 -- Error E2247 test.cpp 11: 'boost::detail::cannot_derive_errorcheck<boost::policy::error_storage<int>,boost::policy::no_errormsg_storage>::cannot_derive_errorcheck()' is not accessible in function foobar::foobar() Therefore, the error message is intuitive: cannot_derive_errorcheck! Regards, Reece _________________________________________________________________ Tired of 56k? Get a FREE BT Broadband connection http://www.msn.co.uk/specials/btbroadband