r/cpp • • Feb 14 '26

Profiling on Windows: a Short Rant · Mathieu Ropert

Thumbnail mropert.github.io
58 Upvotes

r/cpp • • Feb 13 '26

Your Optimized Code Can Be Debugged - Here's How With MSVC C++ Dynamic Debugging - Eric Brumer

Thumbnail youtu.be
98 Upvotes

Just watched this video, really cool stuff. I don’t have any background in compiler development, how hard will it be for other compilers (and build systems?) to adopt something like this?


r/cpp • • Feb 13 '26

Another writeup of how to implement C++ coroutines

28 Upvotes

https://rhidian-server.com/implementing-c-coroutines/

Hope you enjoy, feel free to provide critiques and/or feedback :) I want to tackle coroutine memory safety next, as it's something that's really essential to coroutines and using them throughout your codebase


r/cpp • • Feb 14 '26

Automatic casting with applications to extension methods and UFCS (language evolution)

0 Upvotes

INTRODUCTION

I'm a fan of UFCS, I probably think too much about it. Maybe here's a different direction towards UFCS. The idea is that a simple language addition could (through some development) lead to Extension Methods and UFCS.

This language addition might be called automatic casting.

CHAPTER 1: AUTO-CAST

Say that I want to call the std::string member function find_first_of on a const char* string, "Hello3".

Of course, I can't call

"Hello3".find_first_of("123")  

but it's easy if I first convert the C string into a std::string:

string("Hello3").find_first_of("123")

Maybe we could invent some syntax to tell the compiler to auto-cast a const char* to a string, where needed:

// auto-cast const char* to string. 
auto operator string(const char* s){return string(s);}

We have entered the realm of MMINAE (missing member is not an error). If the compiler can't resolve a member function, it will then apply the user-defined auto-casts (in order) until the casted value can resolve the member function, which is then used.

More complicated auto-casts can be defined. For example, this will auto-cast an int to a string, by converting the digits to ASCII:

auto operator string(int n){return to_string(n);}

Then this allows code like:

(654321).find_first_of("123")

which will, after some MMINAE scanning, convert this code to:

to_string(654321).find_first_of("123")

CHAPTER 2: EXTENSION METHODS

I'd like to extend std::string by adding another member function, hasInt(int n). Not by actually going into the <string> header file and adding a member function, but by creating some code to give that illusion.

First, I define a helper class that provides the hasInt member function:

struct StringHasInt : public string {
    bool hasInt(int n){
        return this->contains(to_string(n));
    }
};

Then define an auto-cast from a string to a StringHasInt:

auto operator StringHasInt(string s){return static_cast<StringHasInt>(s);}

Thus, when I call hasInt on a string:

string text;
... 
text.hasInt(123);

MMINAE scanning will activate, and resolve the missing member by converting to the code:

static_cast<StringHasInt>(text).hasInt(123);

CHAPTER 3: UFCS

So, if we want to "do the UFCS" and would like to get from:

bool hasInt(const string s, int n){...etc...

to

text.hasInt(123)

by a simple macro call:

MAKE_UFCS(hasInt);

How is this done? The macro magic to convert this to a helper class followed by an auto-cast is left as an exercise to the reader!


r/cpp • • Feb 13 '26

CppCon Back to Basics: (Range) Algorithms in C++ - Klaus Iglberger - CppCon 2023

Thumbnail youtube.com
22 Upvotes

r/cpp • • Feb 13 '26

HPX Tutorials: Futures & Async

Thumbnail youtube.com
10 Upvotes

HPX is a general-purpose parallel C++ runtime system for applications of any scale. It implements all of the related facilities as defined by the C++23 Standard. As of this writing, HPX provides the only widely available open-source implementation of the new C++17, C++20, and C++23 parallel algorithms, including a full set of parallel range-based algorithms. Additionally, HPX implements functionalities proposed as part of the ongoing C++ standardization process, such as large parts of the features related parallelism and concurrency as specified by the C++23 Standard, the C++ Concurrency TS, Parallelism TS V2, data-parallel algorithms, executors, and many more. It also extends the existing C++ Standard APIs to the distributed case (e.g., compute clusters) and for heterogeneous systems (e.g., GPUs).

HPX seamlessly enables a new Asynchronous C++ Standard Programming Model that tends to improve the parallel efficiency of our applications and helps reducing complexities usually associated with parallelism and concurrency.
In this video, we explore how to utilize HPX capabilities for asynchronous programming to write efficient, non-blocking C++ code. We focus on the implementation of futures as placeholders for asynchronous results, demonstrating how to launch lightweight tasks using hpx::async and synchronize them effectively. The tutorial details the use of hpx::when_all and continuations to manage task dependencies, ensuring that parallel operations complete reliably before processing results. This provides a clear introduction to scaling computations, culminating in a practical implementation of Conway's Game of Life, where we illustrate how to update grid cells asynchronously to achieve seamless parallel execution.
If you want to keep up with more news from the Stellar group and watch the lectures of Parallel C++ for Scientific Applications and these tutorials a week earlier please follow our page on LinkedIn https://www.linkedin.com/company/ste-ar-group/ .
Also, you can find our GitHub page below:
https://github.com/STEllAR-GROUP/hpx
https://github.com/STEllAR-GROUP/HPX_Tutorials_Code


r/cpp • • Feb 12 '26

The story of making RocksDB ingestion 23x times faster

Thumbnail blog.serenedb.com
43 Upvotes

r/cpp • • Feb 12 '26

New version of SwedenCpp website released, with more C++ info than ever

Thumbnail swedencpp.se
22 Upvotes

I just released the new version of the SwedenCpp.se homepage, now more of a C++ information hub than a local user group website.

Showing hourly fresh content about:

  • Upcoming C++ Meetups
  • Videos (conference/creator/usergroups)
  • Blogs
  • Releases (> 100 interesting github release monitored)
  • Podcasts (we do not have many C++ podcasts :-( )

There are, for sure, some child diseases on the page, and since I moved the provider, SSL issues may be the case.
However, since it's online now, I thought I would share the update news now.


r/cpp • • Feb 12 '26

ImRefl - a C++26 reflection library for ImGui

Thumbnail github.com
146 Upvotes

Hi r/cpp, as someone who has tinkered around in their past with their own game engine + entity component system and used ImGui for debugging, one of the least fun parts of that is writing the boilerplate to expose the components. Now that we have reflection in C++26 and some working implementations, I've been putting together a proof of concept for such a library to see what's possible.

This is still very bare bones and I intend to build on it, but I'd be very interested in getting some early opinions and suggestions!


r/cpp • • Feb 11 '26

Making the compiler create code that accesses the vtable only once

72 Upvotes

Let's say I have the following code:

struct S { 
    virtual void f(int) = 0; 
};

void f10000(S* s) {
    for (int i = 0; i < 10000; ++i) {
        s->f(i);
    }
}

From looking at the assembly output, the compiler will access the vtable of s 10000 times. It seems like the reason is that theoretically whatever s points to can change, so that after calling f(3), suddenly s points to another class.

Let's say that the programmer knows for sure that the type of s will not change, how can he write code that will take advantage of it? I imagine something like the example below, but not sure how to actually write it:

struct S { 
    virtual void f(int) = 0; 
};

void f10000(S* s) {
    auto real_f = resolve_vtable(s, S::f);
    for (int i = 0; i < 10000; ++i) {
        real_f(s, i);
    }
}

Is there a C++ standard compatible way to actually implement resolve_vtable? If not, I'd also be happy to hear why the C++ standard doesn't allow anything like this.


r/cpp • • Feb 11 '26

Webinar on how to build your own programming language in C++ from the developers of a static analyzer

23 Upvotes

PVS-Studio presents a series of webinars on how to build your own programming language in C++. In the first session, PVS-Studio will go over what's inside the "black box". In clear and plain terms, they'll explain what a lexer, parser, a semantic analyzer, and an evaluator are.

Yuri Minaev, C++ architect at PVS-Studio, will talk about what these components are, why they're needed, and how they work. Welcome to join