How to forward declare a class to be used in a standard container of unique_ptr
问题 Is it possible to avoid having full class definition visible when using it in standard container of smart pointers? For example I can't get the following to compile: #include <memory> #include <map> class Foo; class Bar { public: Bar(); std::map<int, std::unique_ptr<Foo>> myMap; }; The Clang compiler seems to insist on having full definition of Foo available when compiling Bar . Is there a technique I could use to avoid having to include Foo.h? Edit1: error: invalid application of 'sizeof' to