Articles & Books

Improved automated instance construction in C++--Marius Elvert

The series continue.

Improved automated instance construction in C++

by Marius Elvert

From the article:

In my last blog post, I wrote about how I am automatically deducing constructor parameters in my dependency injection container. The approach had a major drawback: It worked only for 2 or more parameters, since there was an ambiguity with copy- or move-constructors with exactly one parameter...

Why do arrays have to be deleted via delete[] in C++

This note is for C++ beginner programmers who are wondering why everyone keeps telling them to use delete[] for arrays. But, instead of a clear explanation, senior developers just keep hiding behind the magical "undefined behavior" term. A tiny bit of code, a few pictures and a glimpse into nuts and bolts of the compilers – if interested, you're welcome to read.

Why do arrays have to be deleted via delete[] in C++

by Mikhail Gelvih

From the article:

This pointer in no case should be passed to the usual operator delete. Most likely, it will just remove the first element of the array and leave the others intact. Note that I wrote "most likely" for a reason, because no one can predict every possible outcome and the way the program will behave. It all depends on what objects were in the array and whether their destructors did something important. As a result, we get the traditional undefined behavior. This is not what you would expect when trying to delete an array.

C++23’s Deducing this: what it is, why it is, how to use it

Useful new feature!

C++23’s Deducing this: what it is, why it is, how to use it

by Sy Brand

From the article:

Deducing this (P0847) is a C++23 feature which gives a new way of specifying non-static member functions. Usually when we call an object’s member function, the object is implicitly passed to the member function, despite not being present in the parameter list. P0847 allows us to make this parameter explicit, giving it a name and const/reference qualifiers...

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)...

Porting my first application from Qt5 to Qt6

An overview on the issues face when porting my first application to Qt6

Porting my first Application from Qt5 to Qt6

by Jens Weller

From the article:

Just this week I had the opportunity to recompile one of my Qt Applications to build it with Qt6. Here is some of the results.

The application in question manages parts of the conference, and hence is written in Qt for the UI and uses SQLite as datastorage, so Qt also used for this and as I learned for a few other things too...

C++20 Ranges Algorithms - sorting, sets, other and C++23 updates--Bartlomiej Filipek

The series continue.

C++20 Ranges Algorithms - sorting, sets, other and C++23 updates

by Bartlomiej Filipek

From the article:

This article is the third and the last one in the mini-series about ranges algorithms. We’ll look at some sorting, searching, and remaining algorithms. We’ll also have a glimpse of cool C++23 improvements in this area.

Let’s go...