Articles & Books

Top 20 C++ multithreading mistakes and how to avoid them--Deb Haldar

You use threads? You should know this.

Top 20 C++ multithreading mistakes and how to avoid them

by Deb Haldar

From the article:

Threading is one of the most complicated things to get right in programming, especially in C++. I've made a number of mistakes myself over the years. Most of these mistakes were  luckily caught in code review and testing ; however, some arcane ones did slip through and make it into production code and we had to patch live systems, which is always expensive.

In this article, I've tried to catalog all the mistakes I know of, with potential solutions. If you know any more pitfalls, or have alternative suggestions for some of the mistakes – please leave a comment below and I'll factor them into the article.

C++17 in detail: Parallel Algorithms -- Bartlomiej Filipek

Let’s see how C++17 can make writing parallel code a bit easier.

C++17 in details: Parallel Algorithms

by Bartlomiej Filipek

From the article:

With C++17 we get a lot of algorithms that can be executed in a parallel/vectorized way. That’s amazing, as it’s a solid abstraction layer. With this making, apps is much easier. A similar thing could be achieved possibly with C++11/14 or third-party APIs, but now it’s all in the standard.

Overload 140 is now available

ACCU’s Overload journal of June 2017 is out. It contains the following C++ related articles.

Overload 140 is now available

From the journal:

Editorial: Gnomes and Misnomers.
What's in a name? Frances Buontempo decides some names are better than others.

The Path of the Programmer.
Charles Tolman provides a framework for personal development.

A Usable C++ Dialect that is Safe Against Memory Corruption.
Sergey Ignatchenko continues his investigation of allocators for (Re)Actors.

Metaclasses: Thoughts on Generative C++.
Herb Sutter shows how metaclasses could simplify C++ with minimal library extension.

A C++ Developer Sees Rustlang for the First Time.
Katarzyna Macias provides an introduction to Rust for a C++ developer.

Portable Console I/O via iostreams.
Alf Steinbach describes how his library fixes problems streaming non-ASCII characters in Windows.

A Functional Alternative to Dependency Injection in C++.
Satprem Pamudurthy showcases a functional alternative to dependency injection in C++.

About the C++ Core Guidelines.
Andreas Fertig shows us the C++ core guidelines.

Afterwood.
Chris Oldwood reminds us to fix the problem, not to blame.

Quick Q: Make C++ fail compilation on specific instantiation of template function

Quick Q: Delete its constructor

Recently on SO:

Make C++ fail compilation on specific instantiation of template function

Since foo is a complete specialization, it will always get compiled, and the static assert will always get called.

However, there’s an easier way:

template <>
Bar foo<Bar>(Bar val) = delete;

This will say that this specific version is deleted, and cannot be called.

Ranges, Coroutines, and React: Early Musings on the Future of Async in C++ -- Eric Niebler

Eric Niebler shares his thoughts about the interaction of ranges and co-routines in his recent blog post.

Ranges, Coroutines, and React: Early Musings on the Future of Async in C++

by Eric Niebler

From the article:

Another way to look at this is that synchronous ranges are an example of a pull-based interface: the user extracts elements from the range and processes them one at a time. Asynchronous ranges, on the other hand, represent more of a push-based model: things happen when data shows up, whenever that may be. This is akin to the reactive style of programming.

By using ranges and coroutines together, we unify push and pull based idioms into a consistent, functional style of programming. And that’s going to be important, I think.

Your own error condition--Andrzej Krzemieński

The series continues.

Your own error condition

by Andrzej Krzemieński

From the article:

In the previous post we have seen how you can create your own error-code enumeration for representing different reasons for failure in your component, and how you can store them and convey them type erased via std::error_code. In this post we will see how you can inspect an error situation encoded in std::error_code, and how you can build useful queries about error conditions.