Boost logo

Boost Users :

From: gast128 (gast128_at_[hidden])
Date: 2008-03-27 13:13:21


Dear all.

I was googling about incomplete types and smart pointers but couldn't find a
definitive statement about intrusive pointers.

>From the header file of intrusive_ptr it seems that it can deal with
incomplete types. The constructor and destructor use
the 'intrusive_ptr_add_ref' or 'intrusive_ptr_release'. If these are not
invoked, use of an intrusive_ptr with incomplete types should be ok.

So it seems that below example will compile:

//foo.h:
#include <boost/intrusive_ptr.hpp>

class A;

class Foo
{
public:
   Foo();
   ~Foo(); //leave the dtor out, and it won't work

   boost::intrusive_ptr<A> m_ptr;
};

//bla.cpp:
#include "foo.h"

void F()
{
   Foo foo;
}

Is this correct? Or is my (non confirming?) compiler giving me the wrong
impression. A good article about incomplete types is 'The Standard Librarian:
Containers of Incomplete Types' from Austern. He states that member function
which are not referenced in the client code are not checked for incomplete
types. For intrusive_ptr this would be the constructor and destructor.

wkr,
me


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