May 2021

How to Insert Several Elements in a Vector (With No Memory Errors)--Jonathan Boccara

How do you do it?

How to Insert Several Elements in a Vector (With No Memory Errors)

by Jonathan Boccara

From the article:

Inserting elements in a vector sounds like the most basic use case we can think of when it comes to using collections in C++.

Nevertheless, this is a complex topic in itself, because std::vector offers various ways to insert several elements. Choosing the most appropriate depending on your exact use case allows to write more expressive code. And misusing the interface of std::vector can lead to memory errors.

Let’s navigate the various ways to insert several elements in a vector in a safe way, so that you can choose the one that fits best for your code...

Compile-time pre-calculations in C++--Mohammad Nasirifar

The evolution.

Compile-time pre-calculations in C++

by Mohammad Nasirifar

From the article:

With C++17’s constexpr functions and C++20’s consteval specifier, it is easy to do io-independent pre-calculations of algorithms while compiling the program. This may not be useful or even possible in long running programs and is unlikely to make a difference in their performance, but in binaries that do short calculations with a set of parameters fixed at compile-time, a Sieve of Eratosthenes array, or roots of unity used for calculating DFT loaded right from the binary could make a difference...

East End Functions--Phil Nash

Did you know about those reasons?

East End Functions

by Phil Nash

From the article:

There has been a recent stirring of attention, in the C++ community, for the practice of always placing the const modifier to the right of the thing it modifies. The practice has even been gifted a catchy name: East Const (which, I think, is what has stirred up the interest)...

PVS-Studio 7.13: Blame Notifier, MISRA

The list of diagnostics supported by MISRA and AUTOSAR continues to grow. We've expanded the Blame Notifier utility's capabilities. The analysis of Ninja projects on Windows has been enhanced and now involves the JSON Compilation Database.

PVS-Studio 7.13

by Andrey Karpov

From the article:

  • The C++ analyzer provides enhanced support of Ninja projects on Windows using JSON Compilation Database (compile_commands.json).
  • The C++ PVS-Studio analyzer spends 10% less time checking source files with the use of the Clang compiler.
  • To check C++ and C# Visual Studio PVS-Studio_Cmd.exe projects, you can pass the suppression file directly. Before this, you could add suppressed warnings only at the projects and solution level.

CopperSpice: Static Things

New video on the CopperSpice YouTube Channel:

Static Things

by Barbara Geller and Ansel Sermersheim

About the video:

In this video we look at some of the places you can use the static keyword, and what it means in these different locations. Is it valid to put a static variable in a header file? Can you use a static constexpr method as a constant expression? Watch our video and find out some of the unusual side effects of static.

Please take a look and remember to subscribe!

C++20 Ranges are complete in Visual Studio 2019 version 16.10--Casey Carter

No reason not to use them.

C++20 Ranges are complete in Visual Studio 2019 version 16.10

by Casey Carter

From the article:

We are proud to announce completion of our implementation of C++20 Ranges in the Standard Library in the VS2019 v16.10 release under/std:c++latest. We announced the first useful user-visible parts of Ranges in VS 2019 v16.6 in mid 2020, the trickle accelerated into a gushing stream, and the final parts are now in place. This represents a huge body of work with input from multiple open-source contributors over the last two years...

Class Templates--Rainer Grimm

The series continue.

Class Templates

by Rainer Grimm

From the article:

A function template represents a family of functions. Accordingly, a class template represents a family of classes. Today, I want to introduce class templates...

Building LLVM in 90 seconds using Amazon Lambda--Nelson Elhage


Building LLVM in 90 seconds using Amazon Lambda

by Nelson Elhage

From the article:

Last week, Frederic Cambus wrote about building LLVM quickly on some very large machines, culminating in a 2m37s build on a 160-core ARM machine.

I don’t have a giant ARM behemoth, but I have been working on a tool I call Llama, which lets you offload computational work – including C and C++ builds – onto Amazon Lambda. I decided to see how good it could do at a similar build...