Articles & Books

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.

C++ User Group meetings in January 2020

The monthly overview on upcoming C++ User Group meetings all over the world!

C++ User Group meetings in January 2020

by Jens Weller

From the article:

Happy new years! The year has begun, and lots of C++ User Groups have their first meeting of 2020.

Would like to start your own group or looking for ideas in running your current group? Watch my talk from CppCon:

CppCon YT - CppCon 2019: Jens Weller “Starting and Running C++ User Groups”