Maintaining libraries in multiple formats are a bad idea
Library authors shouldn't maintain header only/ header source/ module libraries in one repo. It is a bad idea.
First of all library authors assume if tests succeed on header only format it also works on modules, which is not correct.
Second, the compilation and packaging becomes very ugly, it looks similar to c++ standard versioning macros. Like a project should only compile on one standard, and the other users should either stick to a version/branch or kick rocks.
It is very pleasant to just use modules for libraries, everything is clean. By adopting a support everything approach, library authors harm themselves first and then everyone else because everything lags down.
https://redd.it/1sufvwe
@r_cpp
Library authors shouldn't maintain header only/ header source/ module libraries in one repo. It is a bad idea.
First of all library authors assume if tests succeed on header only format it also works on modules, which is not correct.
Second, the compilation and packaging becomes very ugly, it looks similar to c++ standard versioning macros. Like a project should only compile on one standard, and the other users should either stick to a version/branch or kick rocks.
It is very pleasant to just use modules for libraries, everything is clean. By adopting a support everything approach, library authors harm themselves first and then everyone else because everything lags down.
https://redd.it/1sufvwe
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
CppCast Looking for Guests
As you may be aware - I've restarted [CppCast](https://cppcast.com/) (every 4th week in a rhythm with [C++Weekly](https://www.youtube.com/@cppweekly)) with u/mropert as my cohost.
We are trying to focus on new people and projects who have never before been on CppCast. I have been trolling the show and tell posts here for potential guests and projects.
But I want to ask directly - if you are interested in coming on the podcast to talk about your project / presentation / things you are passionate about and have never before been on CppCast, please comment!
A couple of notes:
* please don't be offended if I don't respond to your post, I have a very busy travel and conference schedule coming up (I'll see you at an upcoming conference!)
* if you're interested please pay attention for a DM so we can get the conversation started.
* being only 1 podcast per month, we don't need a ton of guests, and it might be a few months before your specific interview gets aired
Thank you everyone!
https://redd.it/1suls4e
@r_cpp
As you may be aware - I've restarted [CppCast](https://cppcast.com/) (every 4th week in a rhythm with [C++Weekly](https://www.youtube.com/@cppweekly)) with u/mropert as my cohost.
We are trying to focus on new people and projects who have never before been on CppCast. I have been trolling the show and tell posts here for potential guests and projects.
But I want to ask directly - if you are interested in coming on the podcast to talk about your project / presentation / things you are passionate about and have never before been on CppCast, please comment!
A couple of notes:
* please don't be offended if I don't respond to your post, I have a very busy travel and conference schedule coming up (I'll see you at an upcoming conference!)
* if you're interested please pay attention for a DM so we can get the conversation started.
* being only 1 podcast per month, we don't need a ton of guests, and it might be a few months before your specific interview gets aired
Thank you everyone!
https://redd.it/1suls4e
@r_cpp
Cppcast
Home
Defending against exceptions in a scope_exit RAII type
https://devblogs.microsoft.com/oldnewthing/20260424-00/?p=112266
https://redd.it/1sv03wx
@r_cpp
https://devblogs.microsoft.com/oldnewthing/20260424-00/?p=112266
https://redd.it/1sv03wx
@r_cpp
Microsoft News
Defending against exceptions in a scope_exit RAII type
But maybe it's not worth it.
Using Reflection For Parsing Command Line Arguments
I've been very excited about reflection so I built a small library to pass command line arguments
Basic example:
struct Args
{
std::string firstname;
int age;
bool active;
};
// ./program --first-name John --age 99 --active
const auto args = clap::parse<Args>(argc, argv);
assert(args.firstname == "John");
assert(args.age == 99);
assert(args.active);
More interesting example:
struct Args
{
[= clap::Description<"host to connecto to">{}]
std::string host = "localhost";
[=clap::ShortName<'p'>{}]
std::uint16t port;
[[=clap::Env<"RETRYCOUNT">{}]]
std::uint32t retrycount;
std::optional<std::string> logfile;
[[=clap::ShortName<'e'>{}]]
bool encrypted;
[[=clap::ShortName<'c'>{}]]
bool compressed;
[[=clap::ShortName<'h'>{}]]
bool hashed;
};
// ./program -p 8080 -ec
const auto args = clap::parse<Args>(argc, argv);
assert(args.host == "localhost");
assert(args.port == 8080);
assert(args.retrycount == std::stoul(std::getenv("RETRYCOUNT")));
assert(!args.logfile);
assert(args.encrypted);
assert(args.compressed);
assert(!args.hashed);
The amount of code to handle this is actually quite minimal < 500 lines.
There's a few modern goodies that make this code work:
Reflection \[[P2996](https://isocpp.org/files/papers/P2996R13.html)\]
Annotations for Reflection [P3394\]
Contracts \[[P2900](https://isocpp.org/files/papers/P2900R14.pdf)\]
constexpr exceptions [P3068\]
I guess we don't know what "idiomatic" reflection usage is like yet, I'm interested to come back to this code in a years time and see what mistakes I made!
Link to the code: https://github.com/nathan-baggs/clap
Any feedback, queries, questions are welcome!
https://redd.it/1sv4w78
@r_cpp
I've been very excited about reflection so I built a small library to pass command line arguments
Basic example:
struct Args
{
std::string firstname;
int age;
bool active;
};
// ./program --first-name John --age 99 --active
const auto args = clap::parse<Args>(argc, argv);
assert(args.firstname == "John");
assert(args.age == 99);
assert(args.active);
More interesting example:
struct Args
{
[= clap::Description<"host to connecto to">{}]
std::string host = "localhost";
[=clap::ShortName<'p'>{}]
std::uint16t port;
[[=clap::Env<"RETRYCOUNT">{}]]
std::uint32t retrycount;
std::optional<std::string> logfile;
[[=clap::ShortName<'e'>{}]]
bool encrypted;
[[=clap::ShortName<'c'>{}]]
bool compressed;
[[=clap::ShortName<'h'>{}]]
bool hashed;
};
// ./program -p 8080 -ec
const auto args = clap::parse<Args>(argc, argv);
assert(args.host == "localhost");
assert(args.port == 8080);
assert(args.retrycount == std::stoul(std::getenv("RETRYCOUNT")));
assert(!args.logfile);
assert(args.encrypted);
assert(args.compressed);
assert(!args.hashed);
The amount of code to handle this is actually quite minimal < 500 lines.
There's a few modern goodies that make this code work:
Reflection \[[P2996](https://isocpp.org/files/papers/P2996R13.html)\]
Annotations for Reflection [P3394\]
Contracts \[[P2900](https://isocpp.org/files/papers/P2900R14.pdf)\]
constexpr exceptions [P3068\]
I guess we don't know what "idiomatic" reflection usage is like yet, I'm interested to come back to this code in a years time and see what mistakes I made!
Link to the code: https://github.com/nathan-baggs/clap
Any feedback, queries, questions are welcome!
https://redd.it/1sv4w78
@r_cpp
StockholmCpp 0x3D: Intro, Eventhost, Info and the C++ Quiz
https://youtu.be/i9LQS0QvWpw
https://redd.it/1sv5wtm
@r_cpp
https://youtu.be/i9LQS0QvWpw
https://redd.it/1sv5wtm
@r_cpp
YouTube
StockholmCpp 0x3D: Intro, Eventhost, Info and the C++ Quiz
The intro, and the C++ Quiz from the StockholmCpp 0x3D Meetup.
This event was kindly hosted by NetInsight: https://netinsight.net/
Eventpage: https://www.meetup.com/stockholmcpp/events/314211023/
More info about world of C++ on https://swedencpp.se
This event was kindly hosted by NetInsight: https://netinsight.net/
Eventpage: https://www.meetup.com/stockholmcpp/events/314211023/
More info about world of C++ on https://swedencpp.se
Interview with Guy Davidson - the new ISO C++ convener
https://www.youtube.com/watch?v=RppmIyWVw4w
https://redd.it/1svdael
@r_cpp
https://www.youtube.com/watch?v=RppmIyWVw4w
https://redd.it/1svdael
@r_cpp
YouTube
Interview with Guy Davidson - the new ISO C++ convener
Guy Davidson - the new ISO C++ convener was recently our guest to do a live interview with audience questions at Meeting C++ online.
We've talked about C++26 with reflection, contracts and schedulers. Looked at what could make it into C++29 (networking and…
We've talked about C++26 with reflection, contracts and schedulers. Looked at what could make it into C++29 (networking and…
C++ Modules: clangd, go or no go debating on pulling the modules plug on a project
Every now and then, someone asks how C++ modules are going. I am a lead dev (mentioned not for bragging but to emphasize the crushing weight of responsibility) for a robotics project, as we are making a CV codebase from scratch, I have the opportunity to choose the architecture and conventions of the code (even more crushing responsibility).
I have gotten some C++23 codebases with modules set up; however, whenever adding a new module, I have to recompile to get clangd to not spam extra errors. I have been starting to get second thoughts with pushing modules all the way. To avoid the gcc-clangd stuff, I ended up specifying the compiler as clang (although I could use clangd compiler flag remove/add).
The codebase is at a point where I can relatively, easily pull the plug on modules.
Requirements:
1. No vscode or intellisense - I'm tired of vendor lock
2. Clangd, so we have neovim-coc-clangd + vscodium support
3. Sits well with cmake
4. Not really has to sit too well with clangd, as long as it sits well with compile_commands.json since that is a bit more of a decentralized standard for code completion etc.
5. As much as I would be willing to learn to code without code completion, I would prefer to have enough leeway to radicalize newbies to a nvim plugin with vscodium or neovim-coc-clangd + telescope itself \^_\^
Ideals:
1. Codebase can work with as many compilers as possible (as long as they support #pragma once because the time spent on botched header guards + incoming newbies concerns me enough to diverge a lil' bit from standard C++. Also, our CV codebase is one of those projects that isn't meant to be portable. All of our portable code does use header guards to please the great bjorne stroustroup
2. Ease with other code completion tools
Why (for the curious):
1. Vendor lock sucks
2. Proprietary vendor lock sucks even more
3. I have a bone to pick with microslop
4. Because as an embedded project, vscode's oddities disrupts portions of our toolchain from time to time
5. Even though the CV codebase is not embedded, the fact that vscode support for modules was much harder to get than neovim/clangd just left a bad taste in my mouth. Call me unskilled, but it convinced the newer devs to learn modern C++ on pure command line rather than a shiny GUI-based IDE setup :P
For the curiouser: no, we don't use github anymore :P
https://redd.it/1svded9
@r_cpp
Every now and then, someone asks how C++ modules are going. I am a lead dev (mentioned not for bragging but to emphasize the crushing weight of responsibility) for a robotics project, as we are making a CV codebase from scratch, I have the opportunity to choose the architecture and conventions of the code (even more crushing responsibility).
I have gotten some C++23 codebases with modules set up; however, whenever adding a new module, I have to recompile to get clangd to not spam extra errors. I have been starting to get second thoughts with pushing modules all the way. To avoid the gcc-clangd stuff, I ended up specifying the compiler as clang (although I could use clangd compiler flag remove/add).
The codebase is at a point where I can relatively, easily pull the plug on modules.
Requirements:
1. No vscode or intellisense - I'm tired of vendor lock
2. Clangd, so we have neovim-coc-clangd + vscodium support
3. Sits well with cmake
4. Not really has to sit too well with clangd, as long as it sits well with compile_commands.json since that is a bit more of a decentralized standard for code completion etc.
5. As much as I would be willing to learn to code without code completion, I would prefer to have enough leeway to radicalize newbies to a nvim plugin with vscodium or neovim-coc-clangd + telescope itself \^_\^
Ideals:
1. Codebase can work with as many compilers as possible (as long as they support #pragma once because the time spent on botched header guards + incoming newbies concerns me enough to diverge a lil' bit from standard C++. Also, our CV codebase is one of those projects that isn't meant to be portable. All of our portable code does use header guards to please the great bjorne stroustroup
2. Ease with other code completion tools
Why (for the curious):
1. Vendor lock sucks
2. Proprietary vendor lock sucks even more
3. I have a bone to pick with microslop
4. Because as an embedded project, vscode's oddities disrupts portions of our toolchain from time to time
5. Even though the CV codebase is not embedded, the fact that vscode support for modules was much harder to get than neovim/clangd just left a bad taste in my mouth. Call me unskilled, but it convinced the newer devs to learn modern C++ on pure command line rather than a shiny GUI-based IDE setup :P
For the curiouser: no, we don't use github anymore :P
https://redd.it/1svded9
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
How To Write PyTorch C++ Extensions in 2026
https://www.youtube.com/watch?v=v2LcTzpUOYU
https://redd.it/1svx1ea
@r_cpp
https://www.youtube.com/watch?v=v2LcTzpUOYU
https://redd.it/1svx1ea
@r_cpp
YouTube
How To Write C++ Extensions in 2026 - Jane Xu, Meta & Mikayla Gawarecki, Meta
How To Write C++ Extensions in 2026 - Jane Xu, Meta & Mikayla Gawarecki, Meta
Are you writing a C++ custom op extension to PyTorch? It's 2026 and are you still shipping M x N wheels for M CPython versions and N libtorch versions? Did you know you can just…
Are you writing a C++ custom op extension to PyTorch? It's 2026 and are you still shipping M x N wheels for M CPython versions and N libtorch versions? Did you know you can just…
Code Examples From an App Using C++ Modules
https://abuehl.github.io/2026/04/26/code-examples-from-an-app-using-modules.html
https://redd.it/1sw1ten
@r_cpp
https://abuehl.github.io/2026/04/26/code-examples-from-an-app-using-modules.html
https://redd.it/1sw1ten
@r_cpp
Adrian’s Notes
Code Examples From an App Using C++ Modules
We’ve now published a bit more code from our UML Editor Windows app at https://github.com/cadifra/cadifra/tree/2026.5/code. The code follows our “Recommendations for Using C++ Modules”. In a nutshell these are: Prefer small modules Only use partitions if…
Is there a C++ "venv" equivalent?
Python have venv, Rust have cargo, Node have nvm. You clone a repo, run one command, you're in a reproducible environment.
Is there a viable alternative for C++? I don't think standard will ever bother with this and to their defence, not sure if that is even possible.
I've tried Conan, vcpkg, various CMake setups. They're not bad tools, but there's no standard "activation" ritual. No isolated-per-project environment that pins compiler + deps + toolchain together. No single lockfile that means the same thing on my machine, my colleague's machine, and CI. What I keep wanting is something like: "cppenv activate" and suddenly I'm in a clean, isolated, reproducible build environment for that project. Exit it, and my system is untouched. Share a lockfile, and a teammate gets the exact same thing.
How are you handling reproducible build/development environments?
https://redd.it/1sw2x3z
@r_cpp
Python have venv, Rust have cargo, Node have nvm. You clone a repo, run one command, you're in a reproducible environment.
Is there a viable alternative for C++? I don't think standard will ever bother with this and to their defence, not sure if that is even possible.
I've tried Conan, vcpkg, various CMake setups. They're not bad tools, but there's no standard "activation" ritual. No isolated-per-project environment that pins compiler + deps + toolchain together. No single lockfile that means the same thing on my machine, my colleague's machine, and CI. What I keep wanting is something like: "cppenv activate" and suddenly I'm in a clean, isolated, reproducible build environment for that project. Exit it, and my system is untouched. Share a lockfile, and a teammate gets the exact same thing.
How are you handling reproducible build/development environments?
https://redd.it/1sw2x3z
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
I made my C++ vector search engine 16x faster by changing data layout, not the algorithm
https://dubeykartikay.com/posts/sembed-engine-vector-search-performance/
https://redd.it/1swbilt
@r_cpp
https://dubeykartikay.com/posts/sembed-engine-vector-search-performance/
https://redd.it/1swbilt
@r_cpp
Kartikay Dubey's Blog
Vector Search Engine Performance: 16x Faster Vamana Search
See how sembed-engine made Vamana vector search 16x faster with flat arrays, lightweight views, squared distances, SIMD-friendly loops, and cached candidate scores.
I built a performance profiling SaaS as a hobby project — inspired by High Performance C++ — and I'd love some feedback from people who actually know profiling
Hi r/cpp,
My name is Sascha Kohler. I'm a hobby programmer — not a professional software engineer — and over the past few months I built something I'm calling **RealBench**: a performance profiling as a service platform for C++, Rust, and Go projects.
# What RealBench does technically
* **C++ core** (`lib/profiler/`): sampling profiler using `perf_event_open` directly — no instrumentation, no code changes. Stack unwinding via `libunwind`, symbol resolution via `libelf` \+ DWARF `debug_info`, C++ demangling via `__cxa_demangle`. Rust gets a separate demangling path. Go uses `--call-graph fp` instead of DWARF because frame-pointer unwinding is what actually works there. Flamegraph SVG generated in C++.
* The C++ library is exposed to Node.js via **N-API bindings** (`node-addon-api`), so the profiling worker runs in Node.js but the heavy lifting stays in C++.
* **Backend**: Hono (TypeScript) + pg-boss job queue (PostgreSQL-native, no Redis) + Cloudflare R2 for flamegraph storage. [Fly.io](https://Fly.io) for hosting. Clerk for secure auth.
* **AI analysis**: Claude takes the hotspot JSON and produces ranked, file-and-line-specific optimization suggestions. Also a reason for counting honest testing users.
* **CI integration**: a GitHub Actions workflow template — upload your binary, get results back
"I remember back those days when using assembly with C. So does this concept of using C++ as the inner workhorse and exposing it to Node.js"
# Where I'm genuinely unsure
That's the main reason for this post.
There are plenty of profiling tools. `perf` is free, Valgrind/Callgrind is free, Tracy is excellent, Orbit exists. I don't know if there's a real market need here. The pitch is "zero setup, CI-native, flamegraph + AI suggestions in one step" — but whether that's enough of an edge over just running `perf` directly, I genuinely can't tell from the inside.
So, guys : I'd love to hear from people who profile C++ code in their day-to-day work. Does the CI integration angle solve a real friction point for you? Is the AI suggestion layer interesting or does it feel like noise? What would actually make you reach for something like this instead of your current toolchain? Or is this just another proof-of-concept, and project number 2456 in my neverending story of proof-of-concepts?
# Try it
* 🌐 **App**: [https://realbench-web.fly.dev](https://realbench-web.fly.dev)
* 💻 **GitHub** (MIT licensed, 'Open core'): [https://github.com/SaschaKohler/realbench](https://github.com/SaschaKohler/realbench)
Completely free during beta. I am living in Austria, so at night I sleep at day I work. When i don't answer immediatly, be patient.
I'll personally respond to everyone who comments. Thanks for reading.
— Sascha
https://redd.it/1swcs94
@r_cpp
Hi r/cpp,
My name is Sascha Kohler. I'm a hobby programmer — not a professional software engineer — and over the past few months I built something I'm calling **RealBench**: a performance profiling as a service platform for C++, Rust, and Go projects.
# What RealBench does technically
* **C++ core** (`lib/profiler/`): sampling profiler using `perf_event_open` directly — no instrumentation, no code changes. Stack unwinding via `libunwind`, symbol resolution via `libelf` \+ DWARF `debug_info`, C++ demangling via `__cxa_demangle`. Rust gets a separate demangling path. Go uses `--call-graph fp` instead of DWARF because frame-pointer unwinding is what actually works there. Flamegraph SVG generated in C++.
* The C++ library is exposed to Node.js via **N-API bindings** (`node-addon-api`), so the profiling worker runs in Node.js but the heavy lifting stays in C++.
* **Backend**: Hono (TypeScript) + pg-boss job queue (PostgreSQL-native, no Redis) + Cloudflare R2 for flamegraph storage. [Fly.io](https://Fly.io) for hosting. Clerk for secure auth.
* **AI analysis**: Claude takes the hotspot JSON and produces ranked, file-and-line-specific optimization suggestions. Also a reason for counting honest testing users.
* **CI integration**: a GitHub Actions workflow template — upload your binary, get results back
"I remember back those days when using assembly with C. So does this concept of using C++ as the inner workhorse and exposing it to Node.js"
# Where I'm genuinely unsure
That's the main reason for this post.
There are plenty of profiling tools. `perf` is free, Valgrind/Callgrind is free, Tracy is excellent, Orbit exists. I don't know if there's a real market need here. The pitch is "zero setup, CI-native, flamegraph + AI suggestions in one step" — but whether that's enough of an edge over just running `perf` directly, I genuinely can't tell from the inside.
So, guys : I'd love to hear from people who profile C++ code in their day-to-day work. Does the CI integration angle solve a real friction point for you? Is the AI suggestion layer interesting or does it feel like noise? What would actually make you reach for something like this instead of your current toolchain? Or is this just another proof-of-concept, and project number 2456 in my neverending story of proof-of-concepts?
# Try it
* 🌐 **App**: [https://realbench-web.fly.dev](https://realbench-web.fly.dev)
* 💻 **GitHub** (MIT licensed, 'Open core'): [https://github.com/SaschaKohler/realbench](https://github.com/SaschaKohler/realbench)
Completely free during beta. I am living in Austria, so at night I sleep at day I work. When i don't answer immediatly, be patient.
I'll personally respond to everyone who comments. Thanks for reading.
— Sascha
https://redd.it/1swcs94
@r_cpp
Fly.io
Build fast. Run any code fearlessly.
"Parse, don't Validate" through the years with C++
https://derekrodriguez.dev/parse-dont-validate-through-the-years-with-c-/
https://redd.it/1swhwhp
@r_cpp
https://derekrodriguez.dev/parse-dont-validate-through-the-years-with-c-/
https://redd.it/1swhwhp
@r_cpp
derekrodriguez.dev
Parse, don't validate through the years with C++ | derekrodriguez.dev
Alexis King’s Parse, don’t validate had a huge impact on how I write code, particularly my stance toward Python type annotations in production. However, as someone who has written practically zero Haskell, the idea didn’t click for me until I started seeing…
The Hidden Performance Price of C++ Virtual Functions
https://www.youtube.com/watch?v=3ux5YEj1c54
https://redd.it/1swma7p
@r_cpp
https://www.youtube.com/watch?v=3ux5YEj1c54
https://redd.it/1swma7p
@r_cpp
YouTube
The Hidden Performance Price of C++ Virtual Functions
General Info
We want to meetup IRL, too! Checkout the website for information on social events this week. Check back weekly, as we announce more. Want to help organize such, yourself? Find us on Discord (check the landing page for info) and help us get back…
We want to meetup IRL, too! Checkout the website for information on social events this week. Check back weekly, as we announce more. Want to help organize such, yourself? Find us on Discord (check the landing page for info) and help us get back…
C++ & OpenGL Spacecraft Navigation: Earth to Moon Trajectory
https://www.youtube.com/watch?v=qHCHyJkCEKs
https://redd.it/1swx6aj
@r_cpp
https://www.youtube.com/watch?v=qHCHyJkCEKs
https://redd.it/1swx6aj
@r_cpp
YouTube
OpenGL C++ Spacecraft Navigation System Test: Earth to Moon Transfer
Testing the navigation system for an Earth to Moon transfer trajectory in my custom C++ and OpenGL spacecraft simulation. The engine handles real orbital mechanics and astrodynamics using the NASA SPICE toolkit to calculate impulsive burns.
C++, OpenGL,…
C++, OpenGL,…