I have a header with forward-declared classes that I want to declare some smart pointer members in. However, since the smart pointer template types are technically incomplete at time of declaration, I'm getting compilation errors regarding sizeof not being able to be used for unique pointers. Do I have to pull in the implementation headers into my class's header, rather than forward-declaring them, or is there an additional stub I can provide to my forward declaration that will satisfy the smart pointers?
For instance, this is the header file:
#include <memory>
namespace N {
class A;
class Owner {
std::unique_ptr<A> myMember;
}
}
And this is the source file:
#include "A.H"
class Owner{
Owner() {
myMember = std::make_unique<A>("arg1", "arg2");
}
}
I'd rather not bleed dependencies to everyone who includes my header, which is why the classes were originally forward declared when I was using raw pointers.