Is there a standard pointer class (or Boost) which is a non-shared pointer that works with incomplete types? I've gone over the C++11 standard and the boost library and can't find one, though it seems like a very useful type.
For example, I'd like to be able to make opaque types using a smart pointer.
class A;
wrap_ptr<A> some_func();
void other_func( A const & );
A
is an opaque type which can be used for a variety of functions. The user of the above interface has only an incomplete definition of A but should be able to delete/reset the pointer. I know the above can be done with a shared_ptr
but that has an overhead I don't want in this particular code. unique_ptr
has the right ownership semantics, but can't work with an incomplete type. In theory a wrapper should need only the overhead of having a pointer to a deleter.
Is there such a type in C++11 or the boost libraries?
NOTE: I understand I can easily build this type, but I'd prefer a standard type if possible. It seems like it should be a fundamental smart pointer type.
UPDATE: unique_ptr
does not appear to be a good option. First off the syntax overhead would be offsetting. Secondly I'm not convinced it can be safely used with a custom deleter. I'll check to see how it might work.