Learn about generic programming and concepts, views & ranges with Nicolai Josuttis

Meeting C++ is hosting two trainings on the 26th and 27th May with Nicolai Josuttis:

May 26th: Generic programming in C++ with templates and auto

Generic code is key for the success of C++. Almost all parts of the C++ standard library are implemented as templates and with auto. However, the uncertainty when seeing this code and when writing own code is high.

This online training will guide you through the most important elements of generic programming for ordinary application programmers. Based on the general approach for function templates and class templates we cover the more tricky topics like non-type template parameters, variadic templates and fold expressions, class template argument deduction, type traits, and SFINAE.

This can be used as perfect base for the training about C++20/C++23 concepts, which are covered in a training the day after.

 

May 27th: Concepts, Ranges, and Views - The New Way of Programming in C++

Concepts, ranges, and views, introduced with C++20 and extended with C++23, introduce a new way of programming with C++:


    Concepts establish a way to deal with requirements and constraints to simplify overloading and improve error messages of generic code. This sounds simple but changes the way we write code significantly.

    Ranges and views establish a new way to deal with collections and containers. Instead of using begin() and end(), we deal with the collections as a whole. This establishes new ways of data processing (such as defining pipelines) but also introduces new pitfalls and caveats.


Both features were designed together so that they benefit from each other:


    Ranges and views are implemented using concepts to behave well and help with their usage.

    As a consequence, standard concepts were designed according to a real non-trivial application of using them.


This full day tutorial guides you though these new features. The features are motivated and explained so that you understand purpose and design as well as how to use them in practice. This also implies to talk about the most important pitfalls (there are several) so that you avoid wasting time or getting even frustrated by unexpected behavior or strange errors.

 

You also can get both as two in one package.

Using Token Sequences to Iterate Ranges -- Barry Revzin

There was a StackOverflow question recently that led me to want to write a new post about Ranges. Specifically, I wanted to write about some situations in which Ranges do more work than it seems like they should have to. And then what we can do to avoid doing that extra work.

Using Token Sequences to Iterate Ranges

by Barry Revzin

From the article:

The Problem

For the purposes of this post, I’m just going to talk about the very simple problem of:

for (auto elem : r) { 
use(elem); 
} 

In the C++ iterator model, this desugars into something like:

auto __it = r.begin(); 
auto __end = r.end(); 

while (__it != __end) { 
use(*__it); 

++__it; 
} 

I used a while loop here deliberately, because it’s a simpler construct and it lets me write the advance step last.

Now, if you want to customize the behavior of a range, those are your entry points right there. You can change what the initialization phase does (begin() and end()), you can change the check against completeness (__it != __end), you can change the read operation (*__it), and you can change the advance operation (++__it). That’s it. You can’t change the structure of the loop itself.

That alone is enough to offer a pretty large wealth of functionality. It’s a very powerful abstraction.

1-day workshop on May 30: Safe and Efficient C++ for Embedded Environments -- Andreas Fertig

me.pngFriday, May 30th, 2025, 10:00 - 18:00 Berlin time (online)

1-day workshop on May 30: Safe and Efficient C++ for Embedded Environments

by Andeas Fertig

About the training

I'm thrilled to let you know that I'll give the workshop "Safe and Efficient C++ for Embedded Environments".

The workshop will take place on Friday, May 30th, 2025, 10:00 - 18:00 Berlin time. It is a remote workshop, so we can join from everywhere.

The course is specifically for people in the embedded domain. You'll learn about various features of modern C++, as you can see in the outline below:

  • Language features in C++
    • References
    • nullptr
    • Explicit data type conversion
    • Uniform initialization
    • Digit separator
    • auto type deduction
    • range-based for loops
    • Strongly typed enum
    • static or inline
    • Attributes
  • ROM-ability
  • Living without the heap
  • Dynamic memory management
  • alignas & alignof
  • Placement-new
  • Implementing a pool allocator
  • std::launder
  • std::unique_ptr
  • std::start_life_time_as

C++ on Sea 2025 Full Schedule, including workshops

C++ on Sea 2025 runs from 23rd-25th June, with workshops on 26th-27th.

The full 2025 schedule is now available

by C++ on Sea

From the article:

This year we are, once again, running 2-day workshops - but they will be after the main conference, at the end of the week. As usual we have a great range of timely topics from world-class instructors to help you keep ahead.

We'll kick off with [a keynote from] Herb Sutter... regroup in the middle with Timur Doumler... then round out with Kristen Shaker.

Lightning talks... conference dinner... and a C++ quiz night.

 

free performance: autobatching in my SFML fork -- Vittorio Romeo

This article shows how a very simple automatic batching strategy can be applied on top of SFML without affecting the library API, resulting in free performance for the end user!

free performance: autobatching in my SFML fork

by Vittorio Romeo

From the article:

In one of my previous articles, I discussed the design and implementation of the batching system in my fork of SFML. Wouldn’t it be nice if drawables were automatically batched, whenever possible?

AoS vs SoA in practice: particle simulation -- Vittorio Romeo

This article presents a practical benchmark of a particle simulation using both the AoS (Array of Structures) and SoA (Structure of Arrays) data layouts. How much performance can we gain by merely switching up the way our data is stored?

AoS vs SoA in practice: particle simulation

by Vittorio Romeo

From the article:

The benchmark simulates a large number of 2D particles that continuously change position, scale, opacity, and rotation. Through an ImGui-based UI1, you can choose the number of particles, toggle multithreading, and switch between AoS and SoA on the fly.

A demo is worth a thousand words, and since my fork of SFML supports Emscripten, you can try the benchmark directly in your browser. Play around with all the options – I’m curious to hear what results you get! [...]

CLion Is Now Free for Non-Commercial Use

Great news for C++ enthusiasts working on personal projects! JetBrains has announced that CLion is now available for free for non-commercial use.

CLion Is Now Free for Non-Commercial Use

by JetBrains

From the article:

"Whether you're a student, an Arduino experimenter, or someone who loves С and C++ with all your heart despite all the challenges these languages present, CLion is now available to you for free – as long as you're not using it for commercial work."

Clang 20.1.0 Release Notes - Clang 20.1.0 Documentation

Clang 20.1.0 Release Notes - Clang 20.1.0 Documentation

From the release notes:

C++ Language Changes

  • Allow single element access of GCC vector/ext_vector_type object to be constant expression. Supports the V.xyzw syntax and other tidbits as seen in OpenCL. Selecting multiple elements is left as a future work.
  • Implement CWG1815. Support lifetime extension of temporary created by aggregate initialization using a default member initializer.
  • Accept C++26 user-defined static_assert messages in C++11 as an extension.
  • Add __builtin_elementwise_popcount builtin for integer types only.
  • Add __builtin_elementwise_fmod builtin for floating point types only.
  • Add __builtin_elementwise_minimum and __builtin_elementwise_maximum builtin for floating point types only.
  • The builtin type alias __builtin_common_type has been added to improve the performance of std::common_type.

C++2c Feature Support

C++23 Feature Support

C++20 Feature Support

  • Implemented module level lookup for C++20 modules. (#90154)

Slides of the 22nd of April 2025 BeCPP Meeting

On April 22nd 2025, I organized the next Belgian C++ Users Group event. There were 2 sessions:
- "Algorithm intuition revisited" (Bruno Hendrickx)
- "Compile-Time Emulation of an 8080-Inspired System in C++" (Tom Tesch)

You can find the schedule (with abstracts), slides, and pictures on the BeCPP blog:
Schedule: https://becpp.org/blog/2025/03/16/next-becpp-ug-meeting-planned-for-april-22nd-2025/
Slides: https://becpp.org/blog/2025/05/06/slides-of-the-22nd-of-april-2025-becpp-meeting/
Pictures: https://becpp.org/blog/2025/05/06/pictures-of-the-22nd-of-april-2025-becpp-meeting/