Boost logo

Boost Users :

From: Herve Alexanian (herve_at_[hidden])
Date: 2006-04-27 13:28:18


Hello,

This is my first post regarding boost, I hope I am sending it to the
right list.

I have a question regarding the use of scoped_ptr versus shared_ptr:
I am trying to use scoped_ptr<Impl> to implement the "Pimpl" idiom in
order to hide the Impl definition from the user. Since my class is not
copyable I thought using a scoped_ptr was better suited than a
shared_ptr. So, something like this:

class Impl;
class MyClass {
  scoped_ptr<Impl> m_pImpl;
...
...
};

When compiling client code, I see a checked_delete error. Reading the
blurb about checked_delete this makes sense to me and I am able to work
around the error by putting an explicit destructor declaration in
MyClass. But, I don't see any error if I use a smart_ptr instead of a
scoped_ptr. Why is the requirement about not deleting an incomplete type
any different between scoped_ptr and shared_ptr?

Thanks,
Herve Alexanian
Sonics, inc.


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