
Dear Boost community, I thank you for such wonderful library, I can not even imagine my life without Boost. Great work, team! I propose to add the small but sometimes very useful class (like boost::noncopyable) I developed it in hope it will be useful and included into the best C++ framework in the world. Note that I have tested this class only with: 1) Microsoft Visual C++ .NET 55537-640-4008961-18142 2) Microsoft Visual C++ .NET 69462-112-0617214-18401 But I think it won't be a problem to compile with gcc and so one. And, surely, sorry if there is already such class in the Boost, I did not found. If it is, please give me the link, I will take a look. Please review and let me know what you think by replying to this message. Thank you very much in advance. // // Copyright (c) 2006 Vladislav Lazarenko <snail@b2bits.com> // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_SEALED_HPP #define BOOST_SEALED_HPP // MS compatible compilers support #pragma once. #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif namespace boost { // protection from unintended ADL namespace sealed_ { template <typename T1, typename T2> class sealed_impl { friend typename T1; friend typename T2; private: sealed_impl() {} ~sealed_impl() {} }; } /*! The sealed classes is used to prevent derivation from a class. An error occurs if a sealed class is specified as the base class of another class. A sealed class cannot also be an abstract class. */ template <typename T> class sealed : virtual private sealed_::sealed_impl<sealed, T> { public: //! Constructor. sealed() {} //! Destructor. ~sealed() {} }; // Usage example: /* class UniquePerson : public boost::sealed<UniquePerson> { public: UniquePerson() {} ~UniquePerson() {} }; */ } #endif