Boost logo

Boost Users :

From: Arne Vogel (Arne.Vogel_at_[hidden])
Date: 2005-05-19 05:10:04

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 . 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".


class UsingPimpl {
    struct Impl;
    boost::scoped_ptr<Impl> impl;


    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

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at