Entries by Rainer Grimm

Contracts in C++26

Contracts allow you to specify preconditions, postconditions, and invariants for functions. Contracts should already be part of C++20 but were removed in the standard meeting in Cologne. Here is what Herb Sutter said about contracts on Sutter’s Mill: “contracts is the most impactful feature of C++20 so far, and arguably the most impactful feature we […]

Reflection in C++26: Determine the Layout

Thanks to reflection, you can determine the layout of types. My examples are based on the reflection proposal P2996R5. Class Layout The following program determines the class layout of a few members. // classLayout.cpp #include <experimental/meta> #include <iostream> #include <utility> #include <vector> #include <array> struct member_descriptor { std::size_t offset; std::size_t size; bool operator==(member_descriptor const&) const […]

My ALS Journey (15/n): A typical Day

You may wonder how my day looks. Let me compare a day before ALS with a current day >> My ALS Journey so far << A typical Day My day before ALS is not so exciting. A table will do the job. Currently, all has changed. Now, I have 24/7 support from 4 nurses, together […]

Reflection in C++26: Metafunctions for Enums and Classes

Today, I continue my journey through reflection in C++26 and play with enums and classes. The names of the metafunctions to access an Enum or a Class member are often identical. Access the Members of an Enum The following program is based on one by Daveed Vandevoorde. Daveed is one of the fathers of reflection, […]

Reflection in C++26: Metafunctions

Reflection offers many metafunctions that run at compile time. The metafunctions are declared as consteval. consteval creates a so-called immediate function. Each invocation of an immediate function creates a compile-time constant. To say it more directly. A consteval (immediate) function is executed at compile-time. Read more about consteval and constinit in my previous post: Two […]

Reflection in C++26

After the search into the breadth starts today, the search into the depth: reflection. Reflection Reflection is the ability of a program to examine, introspect, and modify its structure and behavior. Reflection in C++ is more. Here are two statements from the proposal (P2996R5). “We not only want to observe the structure of the program: […]

An Overview of C++26: Concurrency

Today, I will finish my overview of C++26 and write about concurrency. There are still two library features left before I jump into the concurrency: saturation arithmetic and debugging support. Saturation Arithmetic Saturation arithmetic is a version of arithmetic in which all operations, such as addition and multiplication, are limited to a fixed range between […]

My ALS Journey (14/n): My Status Quo

My ALS progression seems to slow down, and Beatrix and I can the first time plan for the future. >> My ALS Journey so far << How to Approach a Cat? There are two ways to approach a cat: first, you feed it something, and second, you play with it. I’m sad to say that […]

An Overview Of C++26: The Library – Math

The most interesting feature of the new C++26 standard library is its improved math support. std::submdspan std::submdspan is s a subspan of an existing span std::mdspan (C++23). The subspan didn’t make it into C++23 and was added with C++26. Before I continue with C++26, I must make a short detour to C++23. hi std::mdspan A […]

An Overview of C++26: The Library

In my last post, I overviewed C++26’s core language. Today, I continue with the library. To make it short. The library does not offer such powerful features as the core language. Let me name them and give you a short example directly from the proposal. std::string and std::string_view Processing The functions around std::string and std::string_view […]