C++ Core Guidelines: Supporting Sections--Rainer Grimm

Table of contents.

C++ Core Guidelines: Supporting Sections

by Rainer Grimm

From the article:

Let's recapitulate. In the last two years, I have written about 100 posts to the C++ Core Guidelines. Why? The document answers:  "This document is a set of guidelines for using C++ well. The aim of this document is to help people to use modern C++ effectively.". But my story does not end here. The guidelines have a supporting section...

Presenter Interviews: Kate Gregory--Kevin Carpenter

Discover the person presenting at CppCon.

Presenter Interviews: Kate Gregory

by Kevin Carpenter

From the article:

In this week’s presenter interview, Kevin Carpenter welcomes back Kate Gregory to preview her upcoming talk Naming is Hard: Let’s Do Better. Kate’s talk will discuss how bad we as C++ developers can be when it comes to naming things and how we could improve.

Quick Q: Where and why do I have to put the “template” and “typename” keywords?

Quick A: to help the compiler understand what the programmer wants.

Recently on SO:

Where and why do I have to put the “template” and “typename” keywords?

In order to parse a C++ program, the compiler needs to know whether certain names are types or not. The following example demonstrates that:

t * f;

How should this be parsed? For many languages a compiler doesn't need to know the meaning of a name in order to parse and basically know what action a line of code does...

Getting Started with the PVS-Studio Static Analyzer for C++ Development under Linux

There are different ways to install PVS-Studio under Linux, depending on your distro type. The most convenient and preferred method is to use the repository, since it allows auto-updating the analyzer upon releasing new versions.

Getting Started with the PVS-Studio Static Analyzer for C++ Development under Linux

by Yuri Minaev

From the article:

Besides strace, you can base the analysis on the compile_commands.json (JSON Compilation Database) file. Many build systems have built-in means of exporting compilation commands, or you could use the BEAR utility to do this. Here's the command to launch the analysis in this case: pvs-studio-analyzer analyze –f /path/to/compile_commands.json

 

Quick Q: What are copy elision and return value optimization?

Quick A: optimisation compilers are allowed to do for perfomance.

Recently on SO:

What are copy elision and return value optimization?

Copy elision is an optimization implemented by most compilers to prevent extra (potentially expensive) copies in certain situations. It makes returning by value or pass-by-value feasible in practice (restrictions apply).

It's the only form of optimization that elides (ha!) the as-if rule - copy elision can be applied even if copying/moving the object has side-effects...

Enabling Polymorphism in SYCL using the C++ idiom "Curiously Recurring Template Pattern"

Dynamic polymorphism is a widely used C++ feature that allows code to be more flexible, and helps create easily extendable interfaces by overriding the base class specified interfaces inside our derived classes. However, in SYCL kernel code in order to emulate dynamic polymorphism we need to use some curious tricks and techniques.

Enabling Polymorphism in SYCL using the C++ idiom "Curiously Recurring Template Pattern"

by Georgi Mirazchiyski

From the article:

The CRTP idiom offers an alternative approach to polymorphism by providing us with the ability to specify static interfaces, where the base class specifies the the structure of the interface, while the derived one represents the implementation. In this case, the base class does represent the interface and the derived class represents the implementation — similar to the general idea of polymorphism.

CopperSpice: Inline Namespaces

New video on the CopperSpice YouTube Channel:

Inline Namespaces

by Barbara Geller and Ansel Sermersheim

About the video:

In this video, we discuss the purpose of namespaces and the functionality C++11 added with the inline namespace syntax. Join us to find out how inline namespaces can help library developers maintain backward compatibility and how they work.

Please take a look and remember to subscribe!

Why Static Analysis Can Improve a Complex C++ Codebase

Gradually and imperceptibly we get the situation when C++ projects’ complexity becomes extreme. Unfortunately, now a C++ programmer can’t be on his own.

Why Static Analysis Can Improve a Complex C++ Codebase

by Andrey Karpov

From the article:

Analyzers know more than even professional developers. It has become too difficult to take into account and remember all the nuances when writing code. For instance, if you haven’t specifically read about it, you’ll never guess that calls to memset function for clearing private data sometimes disappear, as from a compiler’s point of view, a call to memset function is redundant. Meanwhile, it is a serious security defect CWE-14 that is detected literally everywhere.