Articles & Books

How and why overloading, templates, and auto deduction were invented? -- Milad Kahsari

Are you a student and wanted to know How and why overloading, templates, and auto deduction WERE invented? read the following article.

How and why overloading, templates, and auto deduction invented?

by Milad Kahsari

From the article:

Why we need the template function/classes and how this concept created by C++ compiler engineers? In this medium post, I want to go through the steps which made c++ experts think about the template concept and auto in the modern days of software development.

C++ - Initialization of Static Variables--Pablo Arias

A good summary.

C++ - Initialization of Static Variables

by Pablo Arias

From the article:

You are probably reading this because you code in C++. This means that you have battled frustration mastering auto deduction rules or lost your sanity trying to understand why std::initializer_list was considered a good idea. Anyone who has been doing this long enough knows that variable initialization is everything but trivial. It’s a problem too essential to ignore but too challenging to master. Today I’m here to tell you that there is more to it...

2 Lines Of Code and 3 C++17 Features - The overload Pattern--Bartlomiej Filipek

Updated.

2 Lines Of Code and 3 C++17 Features - The overload Pattern

by Bartlomiej Filipek

From the article:

While I was doing research for my book and blog posts about C++17 several times I stumbled upon this pattern for visitation of std::variant:

template<class... Ts> struct overload : Ts... { using Ts::operator()...; };
template<class... Ts> overload(Ts...) -> overload<Ts...>;

With the above pattern, you can provide separate lambdas “in-place” for visitation.

It’s just two lines of compact C++ code, but it packs a few interesting concepts.

Let’s see how this thing works and go through the three new C++17 features that make this patter possible...

C++ coroutines: The problem of the DispatcherQueue task that runs too soon, part 4--Raymond Chen

The series continue.

C++ coroutines: The problem of the DispatcherQueue task that runs too soon, part 4

by Raymond Chen

From the article:

Last time, we made another attempt to fix a race condition in C++/WinRT’s resume_foreground(Dispatcher­Queue) function when it tries to resume execution on a dispatcher queue. We did this by having the queued task wait until await_suspend was finished before allowing the coroutine to resume, and we found a nice place to put the synchronization object, namely in the awaiter, but even with that fix, we introduced additional memory barriers into the hot code path.

But it turns out all this work was unnecessary. We just had to look at the problem a different way.

The purpose of storing the result of Try­Enqueue into m_queued is so that await_resume can report whether the lambda was queued or not. But we can infer that information another way: The fact that our lambda is running means that got got queued. Because if the lambda were not queued, then it would never have run in the first place...

C++ coroutines: The problem of the DispatcherQueue task that runs too soon, part 3--Raymond Chen

The series contine.

C++ coroutines: The problem of the DispatcherQueue task that runs too soon, part 3

by Raymond Chen

From the article:

Last time, we fixed a race condition in C++/WinRT’s resume_foreground(Dispatcher­Queue) function when it tries to resume execution on a dispatcher queue. We did this by having the queued task wait until await_suspend was finished before allowing the coroutine to resume. The hard part was finding a place to put the synchronization object, and we ended up putting it in the queued task’s lambda...

Launching the Meeting C++ Community Survey

Take the Meeting C++ Community Survey!

Launching the Meeting C++ Community Survey

by Jens Weller

From the article:

One thing then often has bugged me when looking at the C++ community is that we don't really had good numbers on most things. Jetbrains, ISOCPP and Bartek's coding blog have launched surveys in the last years, which changed this a little. Also I've been doing some surveys on Twitter, giving some limited insight into C++ related topics. But Twitter surveys are very limited, and for a long time I had an idea on how to make this a continuous survey.