this post was submitted on 02 Jul 2023
6 points (87.5% liked)

C++

1755 readers
1 users here now

The center for all discussion and news regarding C++.

Rules

founded 1 year ago
MODERATORS
 

Using unique_ptr as an example, the presenter talks briefly about the empty object problem, ie when classes have non-zero size despite being empty, and then presents two ways to deal with that:

  • Empty Base Class Optimization (EBCO): exploits the fact that if a base class is empty, it won't increase the size of the derived class. The presenter uses this trick through the cool compressed_pair to have a unique_ptr implementation where the deleter doesn't take an extra byte;
  • [[no_unique_address]] which is a C++20 feature.
no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here