Providing a stable memory address to an external API

A post on how to provide a pointer to a Qt Model/View or other APIs storing pointers to their data without using shared_ptr or unique_ptr for the actual object.

Providing a stable memory address

by Jens Weller

From the article:

Some APIs allow you to store a pointer to your data element. This is used to access additional information from your types to display them in Model/View Architecture.

A while ago I showed how you can implement a tree with shared_ptr and enable_shared_from_this and then display this in QTreeView. And when working on my current project I knew this problem would come around again. Maybe not for a tree and a tree view, but I'll clearly need to have some way to have ui panels display and edit my data classes and store a stable memory adress as a pointer in Qt models. Back in 2015 the Qt5 example still used a pointer allocated with raw new for this, in Qt6 the example uses unique_ptr. Using shared_ptr for this back in 2015 was a good decision, and the code works very well. For the moment I don't see that my current project would need to make use of enable_shared_from_this, so using unique_ptr would be a good option...



Releasing the keynotes of Meeting C++ 2023

Highlighting the current video releases for Meeting C++ 2023: the keynotes

With this year Meeting C++ had a unique set of keynotes, covering 6 impossible problems for software devs with the opening keynote by Kevlin Henney, followed by great wisdom about how open communities thrive by Lydia Pintscher. The closing keynote by Ivan Čukić was an impressive medley composing various idioms with Prog(ressive) C++.

All these keynotes are worth watching, a great contribution to our knowledge base as a community. Thanks to Kevlin Henney, Lydia Pintscher and Ivan Čukić for preparing these great presentations!

Merging intervals in next-gen C++--Marco Arena

Revisiting a classical programming puzzle in next generation C++:

Merging intervals in next-gen C++

by Marco Arena

From the article:

A few weeks ago, I set this problem at Coding Gym: given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input...

About conditional breakpoints

A post on conditional breakpoints, including two surveys about their usage.

About conditional brealkpoits

by Jens Weller

From the article:

A few weeks ago someone asked me for advice on finding a specific bug in a larger C++ code base...

I don't remember much of the details, but one of the challenges was that at least some of the code based used public members, and in order to find the bug a change in these members is what they wanted to understand. Adding out put statements into a setter function wasn't possible, as the code did not have those. My suggestion was using a conditional breakpoint. And it also made me curious, if and how they're used with in our community.

Talks and Speaker for Meeting C++ 2022 released

Since yesterday its possible to have a first look at the program of Meeting C++ 2022

A first view on the talks and speakers of Meeting C++ 2022

by Jens Weller

From the article:

I'm excited to release this update for Meeting C++ 2022: the talks and speakers for this years conference!

As you can see in the talk listing, this is still an ongoing process, getting the speaker pictures from the new speakers for this year will still take a while. Creating the schedule will also take a few weeks, as of now Tracks A and B are planned on site, with Tracks C and D being part of the online part.

Pass-by-value vs Pass-by-reference--James Mitchell

Complex world.

Pass-by-value vs Pass-by-reference

by James Mitchell

From the article:

Let’s dig into the age old question, should you pass-by-value or pass-by-reference in C++? (or by pointer in C)

This blog post is mostly a re-post of a reddit comment that I made on r/cpp about pass-by-value and pass-by-reference, with some minor improvements, to make it easier to reference and save.

The answer isn’t as easy as it might seem, it depends on the Application Binary Interface (ABI) and your use-cases, there isn’t a one size fits all answer, this is even more the case for anything which is built to be cross platform.

First it’s probably good to break the problem down into two parts (focusing solely on performance, ignoring readability and maintainability which should often be more important)

  • The language construct costs (copying, moving, etc)
  • Compiler implications (aliasing, pointer provenance, etc)
  • The ABI (the stack, registers, etc)...

Assignment for optional--Barry Revzin

Highly non trivial.

Assignment for optional<T>

by Barry Revzin

From the article:

Let’s talk about assignment for optional<T>. I realize this is a fraught topic, but I want to try to build up proper intuition about how assignment has to work, especially since the debate around this topic has been fairly underwhelming. This post will almost exclusively discuss copy assignment (i.e. the one that takes an optional<T> const&), since everything just follows from that...

Zero-cost exceptions aren’t actually zero cost--Raymond Chen

The devil is in the details.

Zero-cost exceptions aren’t actually zero cost

by Raymond Chen

From the article:

There are two common models for exception handling in C++. One is by updating some program state whenever there is a change to the list of things that need to be done when an exception occurs, say, because a new exception handler is in scope or has exited scope, or to add or remove a destructor from the list of things to execute during unwinding. Another model is to use metadata to describe what to do if an exception occurs. There is no explicit management of the state changes at runtime; instead, the exception machinery infers the state by looking at the program counter and consulting the metadata...