September 2023

CppCon 2023 std::simd: How to Express Inherent Parallelism Efficiently Via ... -- Matthias Kretz

Registration is now open for CppCon 2023! The conference starts on October 1 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2023!

std::simd: How to Express Inherent Parallelism Efficiently Via Data-parallel Types

Monday, October 2 • 15:15 - 16:15

by Matthias Kretz

Summary of the talk:

C++26 is on route to ship `std::simd`, a facility for expressing data-parallelism via the type system, based on experience from `std::experimental::simd` (Parallelism TS v2). Data-parallel types have the potential to replace many uses of built-in arithmetic types with their `simd` counterpart in compute-intensive workloads, promising factors of speed-ups without algorithmic changes.

This talk presents how data-parallel types are designed to be more than just a thin wrapper around SIMD registers and instructions. They are designed to facilitate generic code, work/integrate with standard algorithms, etc, all while translating into efficient use of parallel execution capabilities. More important, data-parallel types are not "just another way to express data-parallel execution", they also provide new ways to design data structures for efficient memory access (high-throughput without sacrificing locality) using data-structure vectorization. The talk features examples of efficient use of `std::simd`.

Five Advanced Initialization Techniques in C++ -- Bartlomiej Filipek

cppstories-5advinit-fi.pngFrom dynamic container operations to compile-time constants, C++ offers a variety of techniques. In this article, we’ll delve into advanced initialization methods likereserve() and emplace_backfor containers to tuples with piecewise_construct and forward_as_tuple. Thanks to those techniques, we can reduce the number of temporary objects and create variables more efficiently.

Five Advanced Initialization Techniques in C++: From reserve() to piecewise_construct and More

By Bartlomiej Filipek

From the article:

As a background, we can use the following class that will be handy to illustrate when its special member functions are called. That way, we’ll be able to see extra temporary objects.

 

CppCon 2023 Continuous Regression Testing for Safer and Faster Refactoring -- Pejman Ghorbanzade

Registration is now open for CppCon 2023! The conference starts on October 1 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2023!

Continuous Regression Testing for Safer and Faster Refactoring

Monday, October 2 • 15:15 - 16:15

by Pejman Ghorbanzade

Summary of the talk:

Making code changes to real-world software systems runs the risk of introducing unintended side-effects that are costly to find and fix. To mitigate this risk, engineering teams significantly invest in adopting various software testing practices. Despite best efforts, effectively and reliably identifying software regressions remains a challenge and results in long feedback cycles that hurt developer productivity. This problem is more pronounced in C++ software systems, given that their application domains often impose tight requirements on system safety and performance.

This talk shows you how continuous regression testing can help you find regressions in behavior or performance of your software during the development stage. It is a practical walk-through of how to build a regression testing framework in C++, how to use it to write effective regression tests, and how to integrate it with your CI pipeline to automate the execution of your tests as part of the CI or on a dedicated test server. It also includes recommendations on how to avoid common design pitfalls that lead to tests that are either flaky or untrustworthy or difficult to run at scale.

This talk also introduces a free and open-source software for continuous regression testing C++ applications. We will use a series of hands-on demos to showcase the end-to-end workflow of finding regressions in common C++ development scenarios including refactoring functions, upgrading dependencies, and updating the build toolchain. We also show a few less common use-cases such as profiling the size of binaries and tracking the exported symbols of a shared library, to inspire you to think how regression testing could unlock faster and safer refactoring for you and your team.

CppCon 2023 Abstraction Patterns for Cross Platform Development -- Al-Afiq Yeong

Registration is now open for CppCon 2023! The conference starts on October 1 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2023!

Abstraction Patterns for Cross Platform Development

Monday, October 2 • 14:00 - 15:00

by Al-Afiq Yeong

Summary of the talk:

Writing code that's intended to work across multiple platforms; be it hardware, graphics APIs, online storefronts or operating systems can be rather difficult. Many software engineers struggle when it comes to abstracting code especially junior engineers be it for a commercial software or a hobby project. To make matters worse, there's often not a lot of materials covering such as advance topic. This presentation aims to discuss several abstraction patterns that can be used to write cross platform code using the features and tools that C++ and operating system offers, from the bad to the good as well as the benefits and pitfalls of each method in terms of complexity, maintainability and performance. A case study of several cross-platform frameworks will also be included in the presentation. Hopefully this presentation will serve as a starting point and become the main reference for engineers across multiple experience levels across various industries when writing cross platform code.

Inside STL: The lists -- Raymond Chen

Raymond ChenThe C++ standard library type list represents a doubly-linked list, and forward_list is a singly-linked list. Fortunately, the implementations of both of these lists are pretty much what you expect.

Inside STL: The lists

By Raymond Chen

From the article:

Let’s start with the simpler forward_list.

template<typename T>
struct forward_list
{
    forward_list_node<T>* head;
};

template<typename T>
struct forward_list_node
{
    forward_list_node<T>* next;
    T value;
};

The forward_list itself is a pointer to the first element of the list, or nullptr if the list is empty. Each subsequent element contains a pointer to the next element, or nullptr if there is no next element.

CppCon 2023 Things Happening in SG14… -- Patrice Roy

Registration is now open for CppCon 2023! The conference starts on October 1 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2023!

CppCon 2023 Things Happening in SG14…

Monday, October 2 • 14:00 - 15:00

by Patrice Roy

Summary of the talk:

The C++ standards committee is made of a small number of working groups and of a larger number of study groups, including SG14 (low-latency, finances, games and embedded systems). Since pandemic times, SG14 has been brewing a number of proposals meant to make C++ 'better for game developers'. We will look at the principles behind this effort, the output of this work and what this means for C++.

Inside STL: The string -- Raymond Chen

Raymond ChenYou might think that a std::string (and all of its friends in the std::basic_string family) are basically a vector of characters internally. But strings are organized differently due to specific optimizations permitted for strings but not for vectors.

Inside STL: The string

By Raymond Chen

From the article:

The starting point for a std::basic_string is this:¹

template<typename T>
struct basic_string
{
    T* ptr;
    size_t size;
    size_t capacity;
};

The ptr is a pointer to the beginning of the string contents.

The size is the number of characters in the string, not including the null terminator.

The capacity is the string capacity, not including the null terminator.

The picture for this simplified version is as follows:

string-chen.png

CppCon 2023 A Long Journey of Changing std::sort Implementation at Scale -- Danila Kutenin

Registration is now open for CppCon 2023! The conference starts on October 1 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2023!

A Long Journey of Changing std::sort Implementation at Scale

Monday, October 2 • 14:00 - 15:00

by Danila Kutenin

Summary of the talk:

Sorting algorithms have been improving for almost 50 years now with claims of better efficiency and various properties but the question of adopting a new one at scale is often left behind. At Google we replaced std::sort in the LLVM libc++ library to test it for hundreds of thousand calls. We faced many challenges which we had been fixing for 2 years including golden tests, efficiency problems, undefined behavior and broken production. In this talk we want to cover issues on how we improved debugging, benchmarking, how much better a new implementation was compared to the old one and what we have learned on this journey of improved sorting.

CppCon 2023 Back to Basics: Functions -- Mike Shah

Registration is now open for CppCon 2023! The conference starts on October 1 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2023!

Back to Basics: Functions

Monday, October 2 • 14:00 - 15:00

by Mike Shah

Summary of the talk:

Functions are one of the first things programmers learn, granting you the ultimate power to 'resuse' code and build modular programs. In this talk, we are going to provide an overview of functions from the start to the end, on the various powers that are given to us from the ground up. Consider this talk your one stop for learning all of the great things about functions!

We'll start with a basic function example, identifying the function signature and basic abilities of a function. Then we are going to view this function again from the perspective of assembly (using compiler explorer) to show you how a function is structured. From the assembly view, we will then observe that functions have addresses (they must after all!) and that we can store functions in pointers. We'll take a brief aside to show you how modern C++ also gives us the convenient std::function. Functions need not always be 'global' building blocks of our programs, the next step in our journey will be to see how we can have functions at local scope (e.g. lambda's) and how they can be used (and often times in handy ways in the STL). Ah, intrigued are you? We're not quite done! Now with building blocks such as lambda's (and related functors) we can utilize function composition to really unlock the power of functions. Towards the end of this talk, we will talk about grouping related functions (into namespaces) and as member functions in classes. Within our discussion of functions in classes, we'll touch on virtual functions, static functions, and operator overloading. We'll circle back to where we began on these topics, again showing you the assembly. At the end of this talk, you will have had FUN with functions (I couldn't resist...but you will see the complete C++ picture of functions).

CppCon 2023 Lifetime Safety in C++: Past, Present and Future -- Gabor Horvath

Registration is now open for CppCon 2023! The conference starts on October 1 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2023!

Lifetime Safety in C++: Past, Present and Future

Monday, October 2 • 11:00 - 12:00

by Gabor Horvath

Summary of the talk:

How can we make C++ safer without sacrificing its performance and flexibility? Memory safety is a desirable property for any C++ program, but it is not easy to achieve. Recent revisions of the C++ standard rendered some unsafe code ill-formed or harmless, but there are still many gaps. Comprehensive lifetime analysis like that of Rust can help detect memory errors, but it often requires major changes to the code structure. This can be impractical, costly, and risky, especially for legacy code. This talk surveys mitigations available today that can help enhance the safety of our code. These mitigations include warnings and static analysis checks from MSVC, Clang, and GCC, dynamic analysis tools, and changes to the C++ language. It also explores some directions to further improve the safety of the language.