Articles & Books

return first example--Marius Elvert

Clarifying.

return first example

by Marius Elvert

From the article:

It seems my “return first” post was not as enlightening as I had hoped. It was posted on reddit, and while the majority of commenters completely missed the point, it wasn’t really clear for those that did not just read the title. Either way, I am to blame for that – the examples and my reasoning were not very conclusive. So let me try clearing up the confusion with a better example...

Creating a co_await awaitable signal that can be awaited multiple times, part 1--Raymond Chen

Harnessing the power of coroutines.

Creating a co_await awaitable signal that can be awaited multiple times, part 1

by Raymond Chen

From the article:

C++/WinRT asynchronous activities can be awaited only once. This is consistent with their intended usage pattern, which is for an application to start the activity, co_await the result, and then continue.

But maybe you want something like a Win32 event, where any number of people can co_await the event, and then once it is signaled, all the awaiters are resumed...

C++ Concepts: More than Syntactic Requirements--Jonathan Boccara

A new tool to simplify usage.

C++ Concepts: More than Syntactic Requirements

by Jonathan Boccara

From the article:

After years and years of expectation, concepts have finally made it in C++20.

Concepts are descriptions in code of a set of expressions that must be valid with a given type. Those are syntactic requirements. But there is more to concepts than that: concepts also have semantic requirements.

Before getting into that, here is a recap of what concepts are. If you’re already familiar with concepts you can skip to the section on semantic requirements...

My tutorial and take on C++20 coroutines--David Mazières

Detailed and interesting.

My tutorial and take on C++20 coroutines

by David Mazières

From the article:

Over the last 25 years, I’ve written a lot of event-driven code in C++. A typical example of event-driven code is registering a callback that gets invoked every time a socket has data to be read. Once you have read an entire message, possibly after many invocations, you parse the message and invoke another callback from a higher layer of abstraction, and so forth. This kind of code is painful to write because you have to break your code up into a bunch of different functions that, because they are different functions, don’t share local variables...

GotW #100 Solution: Preconditions, part 1 -- Herb Sutter

Solution just posted:

GotW #100 Solution: Preconditions, Part 1

by Herb Sutter

From the article:

We've seen how postconditions are directly related to assertions (see GotWs #97 and #99). So are preconditions, but that in one important way makes them fundamentally different. What is that? And why would having language support benefit us even more for writing preconditions more than for the other two?

A Recap on string_view--Jonathan Boccara

Back to the basics.

A Recap on string_view

by Jonathan Boccara

From the article:

The string capabilities of C++ have little evolved since C++98, until C++17 brought a major evolution: std::string_view.

Let’s look at what string_view is about and what it can bring to your code, by making it more expressive and making it run faster...

unique_ptr, shared_ptr, weak_ptr, or reference_wrapper for class relationships -- Hitesh Kumar

Expressing class relationships with unique_ptr, shared_ptr, weak_ptr, and reference_wrapper.

unique_ptr, shared_ptr, weak_ptr, or reference_wrapper for class relationships

by Hitesh Kumar

From the article:

Classes communicate with each other by having handles as members that refer to other classes. The choice of those referring-handles (e.g., pointers or references) is mostly driven by ownership or control-over-lifetime semantics.

Modern C++: Safety and Expressiveness with override and final

Back to basics.

Modern C++: Safety and Expressiveness with override and final

by Bartlomiej Filipek

From the article:

While C++11 is with us for a decade now, it’s good to go back and recall some of its best features. Today I’d like to consider override and final keywords which add a crucial safety when you build class hierarchies with lots of virtual member functions.

See how to prevent common bugs, and how to leverage tools to make your code safer...