Vladimir Krasovsky wrote:
Hello Arne,
scoped_ptr cannot be used with incomplete types, unfortunately, and thus is not available for use in the pimpl idiom.
Please read http://www.boost.org/libs/smart_ptr/scoped_ptr.htm . Near the end of page you can see "One common usage of scoped_ptr is to implement a handle/body (also called pimpl) idiom which avoids exposing the body (implementation) in the header file."
Examples are also there.
Hello Vladimir, I stand corrected. So it's actually not "scoped_ptr cannot be used with incomplete types" but "scoped_ptr's destructor cannot be instantiated with incomplete types". So class UsingPimpl { private: struct Impl; boost::scoped_ptr<Impl> impl; public: UsingPimpl(); void doSomething(); }; won't work, but by adding UsingPimpl's destructor declaration (to inhibit automatic generation) to the definition of UsingPimpl, and the destructor's definition (after UsingPimpl::Impl has been defined) to the implementation file, it can be made to work. Thanks a lot, Arne Vogel