Boost logo

Boost Users :

From: Jim Hyslop (jim.hyslop_at_[hidden])
Date: 2002-04-29 15:01:48


The documentation at http://www.boost.org/libs/smart_ptr/shared_ptr.htm
states that "T may be void, but in that case, either an explicit delete
function must be passed in, or the pointed-to object must have a trivial
destructor."

I notice that the implementation available at boost.org does not allow
the single-argument ctor to be called on an incomplete type, e.g.:

class simple;
simple * createSimple();

shared_ptr<simple> simpleFactory()
{
    return shared_ptr<simple>(createSimple());
}

The documentation on the single-argument ctor, though, does not state
that T must be a complete type. Is the implementation stricter than the
documentation, or is the documentation incomplete?

I'm writing an article on the smart pointers for the CUJ, and I'd like
to know if I can correctly state "The default behavior for shared_ptr is
to require complete types. You can, however, manage an incomplete type
if you provide a function or function object, which will be called when
the owned object is destroyed."

-- 
Jim

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