
----Original Message---- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Sebastian Redl Sent: 07 April 2006 16:14 To: boost@lists.boost.org Subject: Re: [boost] Sealed C++ class.
Vladislav Lazarenko wrote:
template <typename T> class sealed : virtual private sealed_::sealed_impl<sealed, T>
Interesting idea. Any particular reason why this inheritance is virtual? sealed_impl being a template should be rare to duplicate as a base, and having no data members or virtual functions, it should be irrelevant even if it was duplicated. On the other hand, you introduce the troubles that come with virtual inheritance.
Sebastian Redl
If I write class Broken : public UniquePerson {}; Then the constructor of Broken has to invoke the constructor of sealed_impl. However the constructor is private, so it can't. The result is a compilation error. The problem is the code: template <typename T1, typename T2> class sealed_impl { friend typename T1; friend typename T2; ... 7.1.5.3 p2 says "[Note: this implies that, within a class template with a template type-parameter T, the declaration friend class T; is ill-formed.]" In other words, you can't do that :-( -- Martin Bonner Martin.Bonner@Pitechnology.com Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ, ENGLAND Tel: +44 (0)1223 203894