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.

Comparisons in C++20--Barry Revzin

Get familiar with it, it's coming and it's going to help you!

Comparisons in C++20

by Barry Revzin

From the article:

Now that the Cologne meeting is over and we’ve more or less finalized (at least before the NB comments come in) C++20, I wanted to take the time to describe in detail one of the new language features we can look forward to. The feature is typically referred to as operator<=> (defined in the language as “three-way comparison operator” but more colloquially referred to as “operator spaceship”), but I think it has broader scope than that.

We’re not just getting a new operator, we’re significantly changing the semantics of how comparisons work at a language level...

Trip Report: C++ Standards Meeting in Cologne, July 2019--Botond Ballo

Lots happened!

Trip Report: C++ Standards Meeting in Cologne, July 2019

by Botond Ballo

From the article:

Last week I attended a meeting of the ISO C++ Standards Committee (also known as WG21) in Cologne, Germany. This was the second committee meeting in 2019; you can find my reports on preceding meetings here (February 2019, Kona) and here (November 2018, San Diego), and previous ones linked from those. These reports, particularly the Kona one, provide useful context for this post...

Secure Coding in C/C++ with Robert C. Seacord of NCC Group

In episode 35 of The Secure Developer with Robert C. Seacord of NCC Group

 

Secure Coding in C/C++

with Robert C. Seacord of NCC Group

 

In episode 35 of The Secure Developer, Guy is joined by Robert C. Seacord of NCC Group, who champions the continued practice of coding security in C and C++, and offers practical advantages to using various programming languages in the Agile era.

CLion 2019.2 has landed with more support for Embedded Dev, MSVC debugger, Unused Includes, and more

This year's second major update, CLion 2019.2, has just landed!

CLion 2019.2 has landed with new functionality for Embedded Developers, experimental MSVC debugger, updated Unused Includes check, parameter hints, and much more

by Anastasia Kazakova

From the article:

  • For Embedded developers:
    • On-Chip debugging with GDB Server
    • A Peripheral View for ARM Devices
  • In the debugger:
    • Completion for GDB/LLDB commands
    • On-the-fly detection of pending, resolved, and invalid line breakpoints
    • An experimental debugger for the Microsoft Visual C++ toolchain
    • Go to address and ASCII view in Memory View
  • In the editor:
    • The 'Unused Includes' check is back and now more accurate
    • Updated Clang-Tidy brings a set of new checks to CLion
    • Parameter Name Hints added to make your code easier to read
    • Code assistance in ClangFormat config files
  • Performance improvements
  • Syntax highlighting for over 20 new languages
  • Updates to naming convention settings, bundled Shell Script plugin, and VCS support