Quick Q: Is std::unique_ptr required to know the full definition of T?

Quick A: For certain members only.

Recently on SO:

Is std::unique_ptr<T> required to know the full definition of T?

Most templates in the C++ standard library require that they be instantiated with complete types. However shared_ptr and unique_ptr are partial exceptions. Some, but not all of their members can be instantiated with incomplete types. The motivation for this is to support idioms such as pimpl using smart pointers, and without risking undefined behavior...

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.