News

CppCon 2023 Is std::mdspan a Zero-overhead Abstraction? -- Oleksandr Bacherikov

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!

Is std::mdspan a Zero-overhead Abstraction?

Wednesday, October 4 • 15:15 - 16:15

by Oleksandr Bacherikov

Summary of the talk:

C++23 introduces std::mdspan into the standard library as a view over multi-dimensional arrays. This talk will try to establish some of the best practices for using mdspan, and highlight subtleties to be aware of. Taking some basic matrix and image operations, we'll compare the generated assembly to low-level implementations similar to BLAS, and check if mdspan can be used in a way to avoid any overhead. We'll discuss how the results are affected by mdspan design decisions and ABI limitations.

Inside STL: The deque, implementation -- Raymond Chen

RaymondChen_5in-150x150.jpgNow that we understand the design behind the common STL dequeue implementations, we can peek into the implementation details.

Inside STL: The deque, implementation

By Raymond Chen

From the article:

All three of the major implementations of the standard library maintain an array of pointers to blocks, which they confusingly call a “map” even though it is unrelated to std::map. (Even more confusingly, gcc internally uses the term “node” instead of “block”.) Initially, all the pointers in the map are nullptr, and the blocks are allocated only on demand.

We will say that a block is spare if it contains only spare elements.

CppCon 2023 Embracing CTAD -- Nina Ranns

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!

Embracing CTAD

Wednesday, October 4 • 15:15 - 16:15

by Nina Ranns

Summary of the talk:

Class template argument deduction, or CTAD, is a C++17 feature that has divided the experts into those who consider it very helpful and those who wish it never came to be. What is it, how can it make your life easier, and what makes some wary of it ? We explore the answers to all these questions while covering the history and the current state of CTAD, so you too can form your own opinion on the subject.

CppCon 2023 A Case Study on Using std::future for Robot Drivers -- Anthony Baker

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!

Time Is of the Essence: A Case Study on Using std::future for Robot Drivers

Wednesday, October 4 • 15:15 - 16:15

by Anthony Baker

Summary of the talk:

When it comes to robot control software, timing is important. In this presentation, we will examine the trade-offs of an asynchronous approach to writing control software to interface with robot hardware, using modern c++ features, versus a synchronous one. The audience will be introduced to the widely used robot control framework for ROS(Robot Operating System) 2, ros2_control, and a couple of robot drivers utilizing it, one for the Robotiq 2f 85 gripper and one for the Kinova Gen3 robot arm. The presentation will feature quantitative benchmarking data to observe the performance of the asynchronous and synchronous approaches, as well as video examples of both approaches in action on the robot hardware.

CppCon 2023 Exploration of Strongly-typed Units: A Case Study from Digital Audio -- Roth Michaels

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!

Exploration of Strongly-typed Units: A Case Study from Digital Audio

Wednesday, October 4 • 14:00 - 15:00

by Roth Michaels

Summary of the talk:

API or math mistakes with units can cause problems ranging from a digital audio processing outputting silence to crashing your Mars rover—we’ll discuss real-life examples of both!

The combination of user-defined types, conversion operators/constructors, and operator overloading in C++ give us the tools to use strong-types and avoid unit mistakes; std::chrono is a great example of this that everyone should be using. Unfortunately, when dealing with units beyond time many developers still use primitive types encoding units in variable names or comments because the standard does not offer any tools for user-defined units.

In this talk we will look at the mp-units library which has been proposed for standardization in P1935 (A C++ Approach to Physical Units). We will look at the implementation of various units used in digital audio / DSP that go beyond “physical” units and what the experience is like to develop your own units with this library/proposal.

CppCon 2023 Applicative: The Forgotten Functional Pattern -- Ben Deane

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!

Applicative: The Forgotten Functional Pattern

Wednesday, October 4 • 14:00 - 15:00

by Ben Deane

Summary of the talk:

Monads get all the press. Functors are often presented as a prerequisite to monads. Applicative (functor) almost never gets mentioned. But it's massively useful - to the point where a lot of the time when we think about a "monadic interface" what we really want is an applicative interface.

This talk will put applicative in the limelight, showing how it works and why it's so powerful, with lots of examples grounded in code; there are no category theory diagrams in this talk. Attendees will come away with a solid understanding of the applicative pattern and its many uses. And as a byproduct, their opinions of monads will probably change too.

Optionals. Expected. Ranges. Futures. Parsing. Validation. Error Handling. Transforms. Functions themselves. These are all examples where thinking in terms of applicatives (and importantly, NOT just reaching for "a monadic interface") helps us write simpler, more composable code.

If you're kind of fuzzy about functors and monads, what's missing is probably the third piece of the puzzle: applicative.

CppCon 2023 A Journey Into Non-Virtual Polymorphism -- Rudyard Merriam

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 Journey Into Non-Virtual Polymorphism

Wednesday, October 4 • 09:00 - 10:00

by Rudyard Merriam

Summary of the talk:

Join me on an introductory journey into polymorphism that doesn't use class inheritance and virtual functions. I'll share my amazement at how polymorphism permeates C++. Then we'll visit the long-used Curiously Recurring Template Pattern (CRTP) with its modernization using implicit this.

Do you like lambdas? So does the override pattern, which uses them to handle std::tuples and std::variants with std::apply and std::visit.

Want to walk through a container of disparate types invoking their functions? You'll see this and all the above in code examples galore.

Afterward, you'll be eager to learn more on your own!

CppCon 2023 Object Lifetime: From Start to Finish -- Thamara Andrade

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!

Object Lifetime: From Start to Finish

Wednesday, October 4 • 14:00 - 15:00

by Thamara Andrade

Summary of the talk:

beginner, object lifetime, temporary objects

CppCon 2023 Six Ways for Implementing Math Expressions Calculator -- Amir Kirsh

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!

Six Ways for Implementing Math Expressions Calculator

Wednesday, October 4 • 09:00 - 10:00

by Amir Kirsh

Summary of the talk:

The tradeoffs involved in using runtime polymorphism, based on virtual functions, versus static polymorphism, which relies on Templates, are widely discussed. In this presentation, we aim to delve into this subject by demonstrating a straightforward example of creating a Math Expression Calculator. We will begin with examining the basic pointer-based polymorphism, moving to using smart pointers, comparing the usage of unique_ptr vs. shared_ptr, then explore templates and variadic templates while going through additional topics such as templates specialization, constexpr, type traits, C++20 concepts and more.

The talk presents the multi-paradigm power of C++ and is relevant for any C++ developer who is considering different implementation approaches for modeling the different behavior of entities.

Inside STL: unordered_map, unordered_set, unordered_multimap, & unordered_multiset -- Raymond Chen

RaymondChen_5in-150x150.jpgThe C++ standard library provides hash-based associative containers unordered_mapunordered_setunordered_multimap, and unordered_multiset.

All of these collections are hash tables with different payloads. The unordered_map and the unordered_multimap use a std::pair<Key, Value> as the payload, whereas the the unordered_set and the unordered_multiset use a Key as the payload.

Inside STL: The unordered_map, unordered_set, unordered_multimap, and unordered_multiset

By Raymond Chen

From the article:

Conceptually, the hash table consists of a bunch of buckets, and each bucket contains a linked list of the nodes that fall into that bucket. (This design is known as open hashing or separate chaining.) However, that’s not how the information is structured internally, because iterating through a traditionally-structured hash table requires more state than a single pointer: When you reach the end of each hash chain, you need some other information to tell you which chain to enumerate next.

C++ standard library implementations instead structure the hash table like this:

struct hashtable
{
    using hint = std::list<payload>::iterator;

    std::list<payload> list;
    std::vector<hint> buckets;
};

The list is a linked list of payloads, sorted by bucket. The buckets is a vector of iterators (pointers) into the list that tells you where each bucket begins. Each bucket implicitly ends when the next bucket begins, or (for the last bucket) when the end of the list is reached.