Hello everyone and Happy New Year!

I hope you all had a wonderful holiday season and are ready for another year of deep diving into our favorite language.

We kicked off 2026 this past Tuesday, January 13th, with our 82nd session. It was great to see everyone again; our community continues to grow, now reaching 1,874 members!

Our Supporters

Before we jump into the technical highlights, I want to take a moment to thank our sponsors who keep this community thriving.

A huge thank you to JetBrains for sponsoring our meetup fees. These costs aren’t small (reaching into the hundreds), and having their support allows us to focus entirely on the C++ content and our members.

We also want to acknowledge Packt Publishing. I’ve been spending my free time recently with a copy of Software Architecture with C++. It is a massive book – around 700 pages – and while the first few chapters cover the theoretical ground, it gets incredibly advanced from chapter five onwards. If you’re looking to push your boundaries in C++20 and beyond, I highly recommend it. Packt has been kind enough to provide a CPP20 discount code for the ebook if you want to check it out yourself!

The Main Event: C#-Style Properties in C++

Our special guest for the evening was our very own Martin Vorbrodt. Martin has been a staple of the C++ community for years, with a career spanning computer forensics, automated trading, and storage drivers.

Aside from his technical prowess, we also had something to celebrate: Martin is starting a new position next week! Congrats, Martin!

The Motivation

Martin’s talk was based on his recent work implementing C#-style properties in C++. The goal was simple but ambitious: provide the encapsulation of a getter/setter mechanism while maintaining the clean, intuitive syntax of a public data member.

We’ve all been told that public data members are a “big no-no” because you lose control over how data is accessed or modified. Martin’s implementation solves this by using a policy-based design that intercepts read and write operations without requiring the user to call get_x() or set_x() explicitly.

Implementation Highlights

Martin walked us through the <em>property.hpp</em> and <em>property.cpp</em> files from his blog repository. The implementation is a masterclass in modern C++20:

  • Policy-Based Design: The property<T> class template uses policies to control storage and access. The default policy stores the value in memory, but Martin demonstrated an FS Property (File System) policy where the value is actually stored and retrieved from disk.
  • C++20 Concepts: The code uses concepts heavily to enable or disable member methods and operators based on whether the underlying type is a primitive, a container, or a smart pointer.
  • Zero Overhead (Mostly): By default, sizeof(property<T>) is equal to sizeof(T). This is achieved by avoiding storing extra state inside the property itself when possible.
  • Event Dispatching: One of the “killer features” is the ability to register an update procedure. You can subscribe to a property, and whenever its value is modified, your lambda or function is triggered – much like property changed events in C#.
  • Explicit vs. Implicit Access: While it behaves like a variable, Martin specifically made the cast to a non-const reference explicit. This ensures that you don’t accidentally bypass the setter mechanism without meaning to.

Code: https://github.com/mvorbrodt/blog/blob/master/src/property.cpp

Q&A and Caveats

The session included some great discussion. One of the questions raised was about thread safety. Martin noted that the current event dispatching uses a static map, which isn’t thread-safe out of the box, though it could be adapted for thread-local storage or protected with a mutex if needed.

We also talked about “caching” for the File System policy. Currently, it reads/writes to disk on every access, but the beauty of the policy-based design is that a user could easily inherit from the policy to add a caching layer.

Resources and Wrap-up

f you missed the live session or want to revisit the details, you can find the event page, recording, and source code below:

Thank you again to Martin for sharing his work and to everyone who attended and asked questions. It’s a fantastic way to start the year.

See you all in February!

Kobi

Leave a Reply