You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now the spec requires that T is a complete type, I feel like this is a tough requirement since neither shared_ptr nor unique_ptr have this requirement. Is there a way to work around the restrictions? The other pointer types have some specific places where completeness is required and other places where it's not. Maybe some detailed rules could be fleshed out here as well.
The text was updated successfully, but these errors were encountered:
It is not possible to define intrusive_ptr<Foo> where Foo is incomplete. However, we do have a workaround for this:
GIven class Foo, we fabricate a complete type
classFoo_fwd : publicintrusive_base<Foo_fwd>
{
virtual~Foo_fwd(); // remember to define this elsewhere.
};
intrusive_ptr<Foo_fwd> foo_ptr; // valid, because `Foo_fwd` is complete.
But it its intrusive_ptr<Foo> that we would like. We have to make Foo and Foo_fwd convertible to each other:
classFoo : publicFoo_fwd
{
virtual~Foo(); // remember to define this elsewhere.
};
intmain()
{
foo_ptr.reset(new Foo); // conversion from `Foo*` to `Foo_fwd*` is valid.auto other = static_pointer_cast<Foo>(foo_ptr); // static_cast'ing from base to derived is also valid.asserrt(foo_ptr == other);
}
Right now the spec requires that T is a complete type, I feel like this is a tough requirement since neither
shared_ptr
norunique_ptr
have this requirement. Is there a way to work around the restrictions? The other pointer types have some specific places where completeness is required and other places where it's not. Maybe some detailed rules could be fleshed out here as well.The text was updated successfully, but these errors were encountered: