News

Reflection voted into C++26: "Whole new language" -- Herb Sutter

The first trip report from the Sofia meeting is available:

Trip report: June 2025 ISO C++ standards meeting (Sofia, Bulgaria)

by Herb Sutter

From the article:

c26-reflection.pngA unique milestone: “Whole new language”

Today marks a turning point in C++: A few minutes ago, the C++ committee voted the first seven (7) papers for compile-time reflection into draft C++26 to several sustained rounds of applause in the room. I think Hana “Ms. Constexpr” Dusíková summarized the impact of this feature best a few days ago, in her calm deadpan way… when she was told that the reflection paper was going to make it to the Saturday adoption poll, she gave a little shrug and just quietly said: “Whole new language.”

Mic drop.

CppCon 2024 Modern C++ Error Handling -- Phil Nash

modernerror-nash.pngRegistration is now open for CppCon 2025! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2025!

Modern C++ Error Handling

by Phil Nash

Summary of the talk:

We’ve had exceptions in C++ since before the first standard. C++17 introduced std::optional and C++23 std::expected (along with the so-called Monadic Operations for both types).

What should we use and when?

Meanwhile we still have older approaches, such as boolean or error code returns, as well as global or thread local error status or pointer or reference arguments.

Do these still have a place?

And where does assert fit in? And the (hopefully) upcoming contracts?

Perhaps more importantly, once we’ve examined all the trade-offs, can we defer any of those decisions to when we are best positioned to commit to them?

Erroneous conditions can have a big impact on your code’s safety and security, so error handling shouldn’t just be left to the “exercise left for the reader” in the books we used to read. Let’s get this all straight.

Implementing a Struct of Arrays -- Barry Revzin

Data-oriented design is all about reorganizing data for better performance, and Andrew Kelley’s talk on the topic—especially his use of Zig’s MultiArrayList—offered a compelling real-world example. Inspired by that, this post explores how we can achieve a similar “struct-of-arrays” approach in C++26 using reflection to build a SoaVector<T> that separates member storage for improved memory locality and performance.

Implementing a Struct of Arrays

by Barry Revzin

From the article:

Recently, I watched Andrew Kelley’s talk on Practical Data Oriented Design. It goes into some of the architectural changes he’s been making to the Zig compiler, with pretty significant performance benefit. Would definitely recommend checking out the talk, even if you’re like me and have never written any Zig.

About halfway through the talk, he shows a way to improve his memory usage by avoiding wasting memory. By turning this structure:

const Monster = struct { 
    anim : *Animation, 
    kind : Kind, 

    const Kind = enum { 
    snake, bat, wolf, dingo, human 
    }; 
}; 

var monsters : ArrayList(Monster) = .{}; 

into this one:

var monsters : MultiArrayList(Monster) = .{}; 

ArrayList(Monster) is what we could call std::vector<Monster>, and MultiArrayList(Monster) now stores the anims and kinds in two separate arrays, instead of one. That is, a struct of arrays instead of an array of structs. But it’s a tiny code change.

CppCon 2024 How Far Should You Indent Your Code? - The Number Of The Counting -- Dave Steffen

indent-steffen.pngRegistration is now open for CppCon 2025! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2025!

Lightning Talk: How Far Should You Indent Your Code? - The Number Of The Counting

by Dave Steffen

Summary of the talk:

Coding Standards have to say something about how we indent our code.  Is there a definitive answer?

C++20 Concepts for Nicer Compiler Errors -- Daniel Lemire

image-33-825x510.jpgTemplates are one of C++’s most powerful features, enabling developers to write generic, reusable code—but they come with a cost: notoriously verbose and opaque error messages. With the introduction of concepts in C++20, we can now impose clear constraints on template parameters and get far more helpful diagnostics when something goes wrong.

C++20 Concepts for Nicer Compiler Errors

by Daniel Lemire

From the article:

In C++, templates enable generic programming by allowing functions and classes to operate on different data types without sacrificing type safety. Defined using the template keyword, they let developers write reusable, type-agnostic code, such as functions (e.g., template <typename T> max(T a, T b)) or classes (e.g., std::vector), where the type T is specified at compile time.

Historically, the C++ language has tended to produce complicated compiler error messages. The main culprit is template metaprogramming. C++ templates are powerful but complex. When errors occur in template code, the compiler generates long, verbose messages with nested type information, often involving deep template instantiations. A simple mistake in a template function can produce a message spanning multiple lines with obscure type names.

Let us consider an example. In C++, we often use the ‘Standard Template Library (STL)’. It includes a useful dynamic array template: std::vector. A vector manages a sequence of elements with automatic memory handling and flexible sizing. Unlike fixed-size arrays, it can grow or shrink at runtime through operations like push_back to append elements or pop_back to remove them. You can store just about anything in an std::vector but there are some limits. For example, your type must be copyable.

Announcing the 3rd Keynote for Meeting C++ 2025: its Anthony Williams!

With this announcement the keynotes for this years Meeting C++ conference are complete!

Announcing the 3rd Keynote for Meeting C++ 2025: its Anthony Williams!

by Jens Weller

From the article:

Today I have the honor to announce that Anthony Williams completes the keynotes for Meeting C++ 2025!

Anthony Williams is well known for his book "C++ Concurrency in Action", has been an active in the committee through the BSI since 2001. He is well known for his work on concurrency and one of the architects and implementers of std::thread and other concurrency features in C++. He gave an An introduction to multithreading in C++20 at Meeting C++ 2022 in the online track. I am looking forward to welcome Anthony in person in Berlin this year!

CppCon 2024 Guide to Linear Algebra With the Eigen C++ Library -- Daniel Hanson

guidetolinear-hanson.pngRegistration is now open for CppCon 2025! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2025!

Guide to Linear Algebra With the Eigen C++ Library

by Daniel Hanson

Summary of the talk:

Linear algebra is an essential part of scientific programming, particularly in domains such as quantitative finance, data science, physics, and medical research.  It is also relevant to imaging in game development.  As C++ did not have all the convenient built-in multidimensional array capabilities and supporting libraries that came with typical Fortran platforms, scientific programmers making the transition to C++ back in the late 1990’s and early 2000's often found themselves in an inconvenient situation with limited options.  These included building up this functionality mostly from scratch, wrestling with interfaces to numerical Fortran libraries such as BLAS and LAPACK, or somehow convincing management to invest in a third-party commercial C++ linear algebra library.

The situation has improved substantially over the years with the development of several well-regarded open-source linear algebra libraries for C++.  One in particular that has become popular, first released in 2006, is the Eigen library.  It has been adopted for use within both the TensorFlow machine learning library and the Stan Math Library, as well as at CERN, and it can also be found in the implementation of high-performance quantitative trading strategies in C++.

In this talk, we will examine the setup and basics of the Eigen library, followed by a discussion of some of its more advanced features, including applications of matrix decompositions frequently used in quantitative work, as well as its compatibility with STL algorithms.  It will conclude with an overview of how it can be used within the context of the C++26 BLAS interface proposal (P1673), via an interface with std::mdspan now available in C++23.

CppCon 2024 Amortized O(1) Complexity in C++ -- Andreas Weis

amortized-weis.pngRegistration is now open for CppCon 2025! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2025!

Lightning Talk: Amortized O(1) Complexity in C++

by Andreas Weis

Summary of the talk:

We will take a quick look at how amortized analysis for algorithms works. We will use two examples from the standard library to demonstrate this and show how in one place, the standard's interpretation of amortized constant complexity is at odds with the usual use of the term.

CppCon 2024 Using PMR in C++ Embedded Systems for Functional Safety -- Scott Dixon

pmr-dixon.pngRegistration is now open for CppCon 2025! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2025!

Lightning Talk: Using PMR in C++ Embedded Systems for Functional Safety

by Scott Dixon

Summary of the talk:

Dynamic memory is often disallowed in high-assurance, c++ embedded systems but, when examining the reasons why, C++17 Polymorphic Memory Resources emerge as an unexpected solution to enable the use of C++ standard library constructs for such projects. My talk will explore how PMR can be used to meet functional safety requirements and to build embedded systems that are robust, performant, and testable.

C++26: More constexpr in the Standard Library -- Sandor Dargo

SANDOR_DARGO_ROUND.JPGHere are the standard library features that will soon be usable at compile time. One topic is missing: exceptions. As they need both core language and library changes, I thought they deserved their own post.

C++26: More constexpr in the Standard Library

by Sandor Dargo

From the article:

P2562R1constexpr stable sorting

This paper proposes making std::stable_sortstd::stable_partitionstd::inplace_merge, and their ranges counterparts usable in constant expressions. While many algorithms have become constexpr over the years, this family related to stable sorting had remained exceptions — until now.

The recent introduction of constexpr containers gives extra motivation for this proposal. If you can construct a container at compile time, it’s only natural to want to sort it there, too. More importantly, a constexpr std::vector can now support efficient, stable sorting algorithms.

A key question is whether the algorithm can meet its computational complexity requirements under the constraints of constant evaluation. Fortunately, std::is_constant_evaluated() provides an escape hatch for implementations. For deeper details, check out the proposal itself.