Hello everyone,
Super late in writing this summary, can’t believe we are 1 week past the session. I’ve been super busy at work and with Family.
What did we have on the Agenda:
- Guo Ci, our guest speaker, presented 2 techniques that are being used to optimize C++ code. The first is doing binary searches with equal_range (in std::ranges and std) and the second is customizing the three-way comparison operator (<=>). Slides: guoci SDCPPMU presentation
- bio: Guo Ci. Guo is a bioinformatician at the University of Michigan, working in labs doing proteomics and genomics research.
- Adding Default Constructor using
=default;
to your class type.
sdcppmu Youtube recording:
Event page from meetup.com
Summary of the discussions:
- From Guo Ci talk – demonstrated techniques related to spaceship/comparison operator
- Changing order of the non-static data members, changes the default operator<=>
- usage of std::tie and restoring the required order
- Transformation of the data members before comparison, using make_tuple and std::cref
- While float provides partial_ordering, what if we want strong_order?
- Caveats related to std::tuple’s <=>
- Synth-three-way
- Second item from Guo Ci talk – A more generic equal_range
- An optimized way to reduce algorithm complexity, running on a sorted array
- Showed benchmarking comparisons
- Overview from the slides:
Next part of the meeting talked about “Adding Default Constructor using =default; to your class type”. We compared aggregate changes between 17 and 20. For 20, an aggregate cannot have “user-declared or inherited constructors”. 17 could. So 20 is stricter. Examples in the slides from godbolt.
The last part of the session talked about top level const in function deceleration, why clang-tidy complains and the rational behind it.
Thanks for reading!
Kobi