Boost logo

Boost Users :

From: Daniel van der Zee (zee_at_[hidden])
Date: 2002-06-05 16:59:26


You usually use private inheritance for boost::noncopyable, that should
prevent users from casting to boost::noncopyable.

The boost::noncopyable destructor is also protected and *can* only be called
by a derived class.

    class X : private boost::noncopyable {
      public:
        X() { }
        virtual ~X() { }
    };

    int main() {
      boost::noncopyable* x =
           reinterpret_cast<boost::noncopyable*>(new X());
      delete x;
    }

Should give a compile time error like

         cannot access protected member declared in class
       'boost::noncopyable'

Daniel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net