Articles & Books

Announcing the second set of AMAs for Meeting C++ 2021

Today I can share with you the second set of AMAs at Meeting C++ 2021

Announcing the second set of AMAs for Meeting C++ 2021

by Jens Weller

From the article:

This second set of C++ Experts nicely completes the first one. Its now a mix of folks involved with the C++ Standard complimented with experience in C++ and other languages. All of them have made contributions to C++ and our community, very much looking forward to see the set of questions for each of them in November!

C++20 three way comparison operator--Gajendra Gulgulia

The series continue.

C++20 three way comparison operator part 5 and part 6

by Gajendra Gulgulia

From the article:

In the fourth part of the tutorial, I introduced the theoretical ideas behind the return types of the three way operator in C++20 and demonstrated that there might be semantic restrictions on the program that allow for comparison of equivalence instead of equality. Also I demonstrated by a simple example when can two objects be semantically incomparable, even though the syntax of program allows to compare them and how to deal with such cases with the help of operator<=>...

On the perils of holding a lock across a coroutine suspension point--Raymond Chen

The series continue

On the perils of holding a lock across a coroutine suspension point, part 2: Nonrecursive mutexes

On the perils of holding a lock across a coroutine suspension point, part 3: Solutions

by Raymond Chen

From the article:

Last time, we looked at what can go wrong if you hold a recursive mutex across a coroutine suspension point. Do things get any better if you switch to a nonrecursive mutex?

On the perils of holding a lock across a coroutine suspension point, part 1--Raymond Chen

More about coroutines.

On the perils of holding a lock across a coroutine suspension point, part 1: The set-up

by Raymond Chen

From the article:

Say you want to perform a bunch of asynchronous operations involving some object state, but also want to make sure that no other tasks access that object state at the same time. For synchronous code, you would use a traditional synchronization object like a mutex or critical section...

Be Wise, Sanitize - Keeping Your C++ Code Free From Bugs--Marin Peko

All is in the title.

Be Wise, Sanitize - Keeping Your C++ Code Free From Bugs

by Marin Peko

From the article:

For all of the losses it has inflicted, this pandemic has at least made us more conscious about our personal hygiene.

We’re spraying spaces, surfaces and our hands way more often, so why not sanitize our code while we’re at it? After all, software runs the world, and bugs that cause programs to malfunction can cause serious damage – much like their viral counterparts.

If you’re developing in C and C++, you know this all too well. It’s easy to allocate a piece of memory and forget to free it later, or accidentally write past the memory buffer. These issues are extremely hard to find without proper tools and often cause sporadic, sudden crashes.

Using sanitizers as you’re building and testing your program can help you catch a great deal of issues in your source code early on, including memory leaks, buffer overflows and undefined behavior.

Today, we’ll be taking a look at three types of Clang sanitizers, how they’re used and what bugs they can help us nip in the bud.

Let’s spray away!

C++20 three way comparison operator: Part 4--Gajendra Gulgulia

The series continue.

C++20 three way comparison operator: Part 4

by Gajendra Gulgulia

From the article:

In the third part of the tutorial series, I uncovered the mechanics of operator <=> and explained in detail, how the compiler re-writes the comparison expression on a custom object with only operator<=> declared as default and how additionally it can make use of synthesized expression to reverse the operands during expression re-writing process. If you haven’t read the third part, I strongly encourage you to read it before reading this tutorial...

C++20 three-way comparison operator: Part 3--Gajendra Gulgulia

The series continue.

C++20 three-way comparison operator: Part 3

by Gajendra Gulgulia

From the article:

In the second part of the tutorial series, I touched upon the rules of the default operator<=> . Unlike default constructors or destructors, the default version of the <=> is not available automatically but has to be declared in the interface of the class and then only it is available to be used.
In this part of the tutorial series, I’ll explain the mechanics of the default operator<=> to further elucidate the rules of the three-way operator, i.e. what exactly is the compiler doing when it sees an expression a < b on a custom object for which no comparison operator is overloaded but only a default version of the operator<=> is declared...