News

A Month of Writing Reflections-based Code: What have I learned? -- Boris Staletić

Depositphotos_193487310_L.jpgThis post chronicles a month-long experiment using C++26 reflections to automate the generation of pybind11 bindings, blending the promise of modern metaprogramming with real-world complexity. It offers a candid look at what worked beautifully, what fell short, and what future language features could make reflection-driven automation even more powerful.

A Month of Writing Reflections-based Code: What have I learned?

by Boris Staletić

From the article:

I have been trying to automate writing my own pybind11 binding code with the help of C++26 reflections, as implemented by clang-p2996.

There were moments where things went smoothly, but also moments where I missed a feature or two from the world of reflections. Then there is also accidental complexity caused by pybind11 having features which are, at the very least, not friendly for generic binding generation.

Before I begin, a massive thanks to Barry Revzin, Daveed Vandevoorde, Dan Katz, Adam Lach and whoever else worked on bringing Reflections to C++.

Smooth sailing

What we got from the set of reflections papers is awesome. Here's an example of what can be achieved quite easily:

https://godbolt.org/z/jaxT8Ebjf

With some 20 lines of reflections, we can generate bindings that cover:

  • free functions (though not overload sets of free functions - more on that later)

  • structs/classes with

    • a default constructor

    • member functions

    • data members, though always writable from python

You can also see how this easily generalizes to all other kinds of py_class.def_meow(...). Almost... Since C++ does not have "properties" in the python sense, def_property_meow will need special care.

Discovering Observers - Part 3 -- Sandor Dargo

SANDOR_DARGO_ROUND.JPGOver the last two posts, we explored different implementations of the observer pattern in C++. We began with a very simple example, then evolved toward a more flexible, template- and inheritance-based design.

This week, let’s move further — shifting away from inheritance and embracing composition.

Discovering Observers - Part 3

by Sandor Dargo

From the article:

You might say (and you’d be right) that publishers and subscribers can just as well be used as members instead of base classes. In fact, with our previous implementation, handling changes inside subscribers felt more complicated than necessary.

What we’d really like is this: subscribers that observe changes and trigger updates in their enclosing class in a coherent way. As one of the readers of Part 1 pointed out, this can be elegantly achieved if subscribers take callables.

Step 1: Subscribers with callables

We start by letting Subscriber accept a std::function, which gets called whenever the subscriber is updated:

Why can’t std::apply figure out which overload I intend to use? -- Raymond Chen

RaymondChen_5in-150x150.jpgWhen you pass an overloaded function like f to std::apply, the compiler can’t peek inside the tuple to figure out which overload matches—it only sees an ambiguous callable and a single tuple argument. Because overload resolution happens before the tuple is unpacked, you need an extra layer (like a lambda) to forward the unpacked arguments and give the compiler enough information to pick the correct overload.

Why can’t std::apply figure out which overload I intend to use? Only one of them will work!

by Raymond Chen

From the article:

Consider the following:

void f(int, int);
void f(char*, char*);

void test(std::tuple<int, int> t)
{
    std::apply(f, t); // error
}

The compiler complains that it cannot deduce the type of the first parameter.

I’m using std::apply here, but the same arguments apply to functions like std::invoke and std::bind.

From inspection, we can see that the only overload that makes sense is f(int, int) since that is the only one that accepts two integer parameters.

But the compiler doesn’t know that std::apply is going to try to invoke its first parameter with arguments provided by the second parameter. The compiler has to choose an overload based on the information it is given in the function call.

Discovering Observers - Part 2 -- Sandor Dargo

SANDOR_DARGO_ROUND.JPGIn the last post, we built a templated observer framework that let any publisher push strongly-typed messages to its subscribers.
This time we’ll push the design further by trying to let a single publisher handle multiple message types—and we’ll quickly see how that innocent goal invites ambiguity, boilerplate, and some surprising trade-offs.

Discovering Observers - Part 2

by Sandor Dargo

From the article:

Last week, we took the observer pattern from a very simple example and evolved it into a more flexible, template-based implementation in C++. We ended up with abstracted publishers and subscribers, a templated message type for flexibility, and publishers controlling when and how updates are pushed.

This week, we’re going to tackle the challenge of supporting multiple message types in a single publisher.

First attempt: multiple inheritance of templated bases

It’s tempting to provide different specializations for our templates so the same publisher can push different message types.

The final schedule for Meeting C++ 2025 has been published

With today, the final schedule for Meeting C++ 2025 has been published. Tickets for Berlin and online are still available until next week Wednesday!

The last update to the schedule for Meeting C++ 2025

by Jens Weller

From the article:

With release of the static html schedule for the website everything is ready for Meeting C++ 2025!

For a few years now Meeting C++ offers two schedules: the live schedule is coming from the database, which allows us to make changes during the conference. The other schedule is part of the static website and just a single page powered by the C++ CMS from Meeting C++. Due to the 5th track this year I've just had one week before the conference the time to update the website with this now final program for the conference.

 

Celebrating C++’s 40th birthday at C++ Day in Italy

This year marks C++'s 40th anniversary, and at C++ Day 2025 (a proper "wrap-up post" will follow in the next days) we couldn't let the occasion pass without a little celebration!

While there wasn't a cake, we gathered everyone to sing "Happy Birthday, C++":

 

 

Followed by a lively game that mixed 1980s pop culture, ISO C++ trivia, Bell Labs history, and more:

 

  

Over 160 people joined the event, with about 120 staying until the end to play and win some unique prizes: 1980s-style posters featuring movie quotes reimagined with a C++ twist:

 

And we had a winner!

 

 

Also we ran a raffle including all quiz participants:

 

 

The posters also decorated the venue all day long, giving it a warm, retro, and festive feel:

 

 

It was a small but heartfelt way to celebrate four decades of a language that continues to inspire and evolve.

 

Here's to the next 40 years of C++!

Looking at binary trees in C++

While preparing a talk for Meeting C++ 2025 I've started looking into binary trees. And got curious about a different design choice.

Looking at binary trees in C++

by Jens Weller

From the article:

I'm in the process of preparing a quick talk on trees in C++ for Meeting C++ 2025. In order to see what the web offers, I've searched exactly for this, "trees in C++".

This showed that most posts found by duckduckgo or google were about binary trees, and in particular the same or similar implementation of using raw pointers for the left/right elements in the tree. Including using new to allocate for the nodes, only some times the code also bothers with using delete. The basic node class looks like this:

 

Introducing the Constexpr Debugger -- Alexander Karaev

intro_image-1.pngThe new Constexpr Debugger available in the first CLion 2025.3 EAP build allows you to stay in the compiler’s world and see what really happens – by stepping through evaluation, inspecting values, and confirming which if constexpr branch fired. Using it helps you understand exactly what the compiler is doing and fix issues faster.

Introducing the Constexpr Debugger

by Alexander Karaev

From the article:

“Not a constant expression.” You’ve seen the diagnostics and the note trail, but never the actual state. Until now.

Modern C++ pushes more logic into constexpr/consteval: parsers, tables, DSLs, hashing – real code with real branches. When code fails at compile time, you can either try to guess the reason from the compiler’s notes or de‑constexpr it and hope the runtime reproduction matches what the compiler actually did.

The new Constexpr Debugger available in the first CLion 2025.3 EAP build allows you to stay in the compiler’s world and see what really happens – by stepping through evaluation, inspecting values, and confirming which if constexpr branch fired. Using it helps you understand exactly what the compiler is doing and fix issues faster.

Discovering Observers - Part 1 -- Sandor Dargo

SANDOR_DARGO_ROUND.JPGThe goal of this mini-series is to explore the Observer Design Pattern in C++, walking through different implementations and weighing their pros and cons.

Discovering Observers - Part 1

by Sandor Dargo

From the article:

First, let’s briefly recap what the observer pattern is. It belongs to the family of behavioral design patterns.

As a reminder: design patterns are usually grouped into three categories: creational, structural, and behavioral.

You might also have encountered the observer under other names such as listenerevent subscriber, or publisher-subscriber.

The central idea is simple: instead of repeatedly querying an object for information, the querying object (the observer) gets notified automatically when the information holder (the subject) changes. For example, imagine an orchestrator object that needs the latest value of a user setting. Instead of polling the setting every n milliseconds, it can subscribe to value changes and receive notifications whenever a new value is set.

Using the common terminology: there is typically one publisher and one or more subscribers. Subscribers register for events or changes, and whenever an update happens, the publisher notifies them.