Articles & Books

Don’t pass lambdas (or other multi-line entities) as parameters to macros--Raymond Chen

Not helping you.

Don’t pass lambdas (or other multi-line entities) as parameters to macros

by Raymond Chen

From the article:

Consider this macro:

#ifdef DEBUG
#define LOG(value) LogValue(value)
#else
// In production, evaluate but don't log.
#define LOG(value) (value)
#endif

This seems not entirely unreasonable, but bad things happen if you pass a multi-line entity as the macro parameter...

Move smart pointers in and out functions in modern C++

Different options with different meanings.

Move smart pointers in and out functions in modern C++

by Triangles @ Internal Pointers

From the article:

Passing and returning smart pointers to/from functions are operations that require some planning. There are many ways of doing it and picking the right one is not always straightforward. Luckily for us C++ experts have guidelines that shed some light on this task.

Modern dining philosophers -- Lucian Radu Teodorescu

How to solve the dining philosophers problem in 2018? By using tasks. And how to use tasks? Read on...

Modern dining philosophers

by Lucian Radu Teodorescu

From the article:

We give several solutions to the dining philosophers problem, each with some pros and cons. But, more importantly, we walk the reader through the most important aspects of using tasks to solve concurrency problems.

Instead of reaching for our higher-level frameworks, we opted to keep the level of abstractions as close as possible to raw tasks. This way, we hope to guide the reader to understand more about the essence of task-based programming. Our aim is to make the reader comprehend the machinery of composing tasks; those skills should be highly valuable.

The overview of C++20 Range view--Ryou Ezoe

Simple, good.

The overview of C++20 Range view

by Ryou Ezoe

From the article:

The latest C++ draft at the time of writing incorporated The One Ranges Proposal.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4791.pdf

So what is a Range, anyway? The C++ Standard Comittee member, Eric Niebler, summarised it well in this article:

Eric Niebler – Eric Niebler

Actually, he summarised it all too well to the point that his code became almost unreadable to an average C++ programmer. One might say, it's practically useless. So this article serves as a quick tutorial for the Range view...

Quick Q: How to use auto keyword to assign a variable of type uint32_t or uint64_t in C++

Quick A: Write the type!

Recently on SO:

How to use auto keyword to assign a variable of type uint32_t or uint64_t in C++

I'm assuming you're working with the AAA style suggested by Herb Sutter.

In that case, a nice solution is to simply write:

auto variable_name = uint64_t{ 5000000000 };

This is clear, consistent, and explicitly typed with no nasty C-preprocessor necessary.

Swapping the Contents of n Variables -- Paul Keir

Swapping arguments using a fold expression.

Swapping the Contents of n Variables

by Paul Keir

From the article:

C++11's std::swap is a binary function template which exchanges the contents of its two reference arguments. In C++20 std::swap will likely also permit execution at compile-time. In this post we consider a version which can swap the contents of an arbitrary number of arguments using a C++17 fold-expression...

 

Developer Ecosystem 2019 survey by JetBrains

In JetBrains we feel it is important to keep monitoring the changing patterns and trends going on in the Software Development industry. That's why we run this survey yearly, trying to better understand the evolving world of development.

Developer Ecosystem 2019 Survey by JetBrains

by Anastasia Kazakova

About the survey:

In 2017, when we first started, the numbers of C/C++ developers in the survey were quite low:

  • total number of C developers in the survey is 1174, number of developers who use C as a primary dev language is 166
  • total number of C++ developers in the survey is 1713, number of developers who use C++ as a primary dev language is 348

A year after we got more impressive numbers:

  • total number of C developers in the survey is 3371, number of developers who use C as a primary dev language is 1254
  • total number of C++ developers in the survey is 4763, number of developers who use C++ as a primary dev language is 2036

We've learned a lot about language standard usage, compilers, build systems, unit testing frameworks, and other important aspects of C/C++ development from these surveys. Help us make it again this year!