See My Talk: Empty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
Table of Contents
Last Tuesday, 21th July, I had a pleasure to talk about
[[no_unique_address]] on our Cracow C++ User Group online meeting.
Here are the slides and additional comments from the presentation.
Our C++ Cracow User group:
We also experienced the problems related to COVID situation, and for two months - in March and April, we had to cancel our regular monthly meetings. Fortunately, we restarted in May with Google Meet and going online :)
So far, we had two presentations by Andrzej Krzemienski:
And in July I tried to present my material.
The online presentations have their issues (for example, it’s a bit harder to “see” the whole audience and interact easily), but this style also has some positives. For instance, we can record the meetings and put it online. Hopefully, in the future, when things get back to normal, we’ll be able to take advantages of both approaches.
Ok, but here’s my presentation…
Sometime in 2016, I wrote an article about custom deleters for smart pointers.
And there is an interesting property that if you have a
unique_ptr and you provide a stateless functor, then the size of
unique_ptr is just one pointer (not two when you use a function pointer). But at that time, I didn’t investigate what the exact reason behind this capability was.
Then in February 2020, I gave a presentation on our C++ User Group about all of the C++20 features. And among them, there’s a new attribute called
[[no_unique_address]]. At that time, I also had no clear idea of what were the use cases for it.
But then I wanted to understand more of C++20 and somehow those two features: deleters for
[[no_unique_address]] started to “converge”.
As it appears with the new attribute from C++20, we can significantly simplify the code that leverages Empty Base Class Optimisation to create things like “compressed pairs” often used to store stateless callable objects like allocators or deleters.
At some point I compiled my investigation into a separate article for Patrons, and you can access it here: June 24th Updates, News, Plans, C++20 no_unique_address and Polymorphic Allocator, Extra | Bartłomiej Filipek on Patreon.
Here are the slides
And, thanks to our Group main organiser, the talk was also recorded and then uploaded on YT:
(it’s my first online live thing!) :)
If you like to hear more from the Cracow User Group, please join our meetup page. Thanks to the online presence we hope to be more “open” and allow to join the meeting even if you’re not in Cracow :)