Apologize about the delay in posting this. Here are the minutes from the last San Diego C++ Meetup, held on Wed Feb 15 2023 5PM Pacific time. Thank you everyone for joining!

The meetup was recorded and uploaded to sdcppmu YouTube channel here:

San Diego C++ Meetup #74 Youtube recording

So what did we have in this meeting?

First – I presented an interesting Req in Qualcomm ML/AI Cloud group. The req number is 3046377 and you can find it on Qualcomm jobs website.

Next, we went over 4 cppquiz questions. The idea here, besides fun, is to learn new elements and constructs in the language. The cppquiz questions were 333,312,318 and 319. We learned about post increment, struct/class inheritance and members visibility, operator void(), casting to void and finally, ternary operator with class inheritance and implicit conversion using implicit constructor.

Next, we discussed the following use case how-to-prevent-stdfunction-to-bool-conversion-in-c-function-overloading . We demonstrated usage of C++20 concepts (std::invocable) as well as enable_if_t.

The next topic is a very interesting one. Polymorphic arrays pitfalls. segmentation-fault-in-operator-delete . It talks about allocating an array of a derived class type and assigning it to a base class pointer. When we do pointer arithmetic, it’s all messed up, and obviously delete []p will also fail. A good picture of what’s going on can be found here:

polymorphic array done wrong

We demonstrated few alternatives. For example, std::vector<p*> would be a good approach and instead would look like:

Vector polymorphic done right

More info and details in the actual recording.

The last one was about template instantiation, RValue binding to const& vs non const& and the implications. Also mentioned (again) implicit conversion in the same context. The details can be found here: why-does-removing-const-from-the-constructor-parameter-stop-the-class-from-being-instantiated . The actual code is here:

What, The Heck

Long story short, when you have const& the compiler can create temp of What<int> with the which is passed, so it tries to instantiate What<T>(The) and check if this Heck(const What<int>&) can be used . If there is no const, you cannot do such RValue/temp binding hence no need to instantiate What<T>. Though we did mention that Heck(The) constructor will be a better match anyway since it does not require any user defined conversion to happen.

That’s it for this #47 session of sdcppmu. See you next month with a special guest. Will be announced soon!

One Reply to “San Diego C++ Meetup Feb 15 2023 – #47”

Leave a Reply