How can std::unique_ptr have no size overhead?

The reason is that the typename _Dp = default_delete<_Tp> is an empty class and the tuple template employs empty base class optimization.

If you instantiate the unique_ptr with a non-default delete, you should see the size increase.

Leave a Comment