std::pmr::generator, a generator without heap allocation
a4z.noexcept.devA short intro/tutorial about how to use std::pmr::generator
A short intro/tutorial about how to use std::pmr::generator
r/cpp • u/ProgrammingArchive • Apr 13 '26
CppCon
2026-04-06 - 2026-04-12
2026-03-30 - 2026-04-05
C++Online
2026-04-06 - 2026-04-12
Mastering C++ Clocks: A Deep Dive into std::chrono - Sandor DARGO - https://youtu.be/ytI6pzT1Opk
2026-03-30 - 2026-04-05
ADC
2026-04-06 - 2026-04-12
2026-03-30 - 2026-04-05
Meeting C++
2026-04-06 - 2026-04-12
2026-03-30 - 2026-04-05
using std::cpp
2026-03-30 - 2026-04-05
r/cpp • u/Mondash18 • Apr 14 '26
I always look for new resources to learn programming. However, every programming language created there will be a huge documentation that is born with it.
And they are very deep shit.
When you get an error from a compiler, there are these many cryptic messages pooping your entire screen and sometimes it just makes me wonder what they are..
Does anyone even read these for fun?
r/cpp • u/tartaruga232 • Apr 13 '26
The correct fix ... is to attack the root cause and stop implicitly importing the interface of module implementation units.
Adding yet another kind of partition is the wrong way to solve it.
r/cpp • u/Live-Manner2725 • Apr 12 '26
Hi all,
How do you people decide which opensource 3rd party library to include in a production environment, e.g for logging I can use either spdlog, Quill, Log4cplus, etc
Not every system is a HFT, in a general production system, how would you usually decide a library, practically speaking, I can get the logs through all of them but which one you would choose, I just took example of logger libs, it can be anything, I would like to understand how you all come to conclusion! do you usually study the whole library before using it?
r/cpp • u/_Noreturn • Apr 11 '26
I spent the last week hacking a Clang fork to implement a restricted more conservative version of Uniform Function Call Syntax (UFCS) based on Herb Sutter’s P3021.
Curious about your thoughts.
r/cpp • u/Express-Act3158 • Apr 11 '26
i am building a deep learning framework called "Forge" completely from scratch in C++, its nowhere near complete yet, training MNIST Classifier shows a functional core on CPU (i'll add a CUDA backend too). My end goal is to train a modern transformer on Forge.
YT video of MNIST training :- www.youtube.com/watch?v=CalrXYYmpfc
this video shows:
-> training an MLP on MNIST
-> loss decreasing over epochs
-> predictions vs ground truth
this stable training proves that the following components are working correctly:-
--> Tensor system (it uses Eigen as math backend, but i'll handcraft the math backend/kernels for CUDA later) and CPU memory allocator.
--> autodiff engine (computation graph is being built and traversed correctly)
-->primitives -- linear layer, relu activation (Forge has sigmoid, softmax, gelu, tanh and leakyrelu too), CrossEntropy loss function (it fuses log softmax and CE. Forge has MSE and BinaryCrossEntropy too, the BCE fuses sigmoid and BCE) and SGD optimizer (i am planning to add momentum in SGD, Adam and AdamW)
[the Forge repo on GitHub is currently private as its WAP]
My GitHub: github.com/muchlakshay
r/cpp • u/SteveGerbino • Apr 10 '26
When I/O operations return senders, they incur an unnecessary per-operation allocation. This explains why.
| Stream Type | capy::task | bex::task | sender pipeline |
|---|---|---|---|
| Native | 0 | 0 | 0 |
| Abstract | 0 | 1 | 1 |
| Type-erased | 0 | 1 | 1 |
When an I/O stream is type-erased, sender/receiver's connect() produces an operation state whose type depends on both the sender and the receiver. The size is unknown at construction time. It must be heap-allocated per operation. Under awaitables, await_suspend takes a coroutine_handle<> — the consumer type is already erased — so the awaitable can be preallocated once and reused. The allocation cannot be eliminated. It follows from connect producing a type that depends on both the sender and the receiver.
We measured this. The benchmark executes 20,000,000 read_some calls per configuration on a single thread using a stream that isolates the execution model overhead from I/O latency. Five independent runs plus warmup; values are mean ± standard deviation. The benchmark source is public:
https://github.com/cppalliance/capy/tree/develop/bench/beman
Anyone is invited to inspect the code, suggest improvements, and help make it better. The architects of P2300 are especially welcome — their expertise would strengthen the comparison.
Two papers address the cost asymmetry. P4003R0 "Coroutines for I/O" defines the IoAwaitable protocol for standard I/O operations. P4126R0 "A Universal Continuation Model" is purely additive — it gives sender/receiver pipelines zero-allocation access to every awaitable ever written. Together they make coroutines and senders both first-class citizens of the I/O stack.
All values are mean ± stddev over 5 runs (warmup pass discarded). Each table measures one execution model consuming two I/O return types (awaitable and sender). The native column is the model's own I/O type; the other column goes through a bridge.
| Stream Type | sender (native) | awaitable (bridge) |
|---|---|---|
| Native | 34.3 ± 0.1 ns/op, 0 al/op | 46.3 ± 0.0 ns/op, 1 al/op |
| Abstract | 47.1 ± 0.2 ns/op, 1 al/op | 46.4 ± 0.0 ns/op, 1 al/op |
| Type-erased | 57.5 ± 0.0 ns/op, 1 al/op | 54.1 ± 0.1 ns/op, 1 al/op |
| Synchronous | 2.6 ± 0.3 ns/op, 0 al/op | 5.1 ± 0.1 ns/op, 0 al/op |
| Stream Type | awaitable (native) | sender (bridge) |
|---|---|---|
| Native | 31.4 ± 0.2 ns/op, 0 al/op | 48.1 ± 0.3 ns/op, 0 al/op |
| Abstract | 32.3 ± 0.2 ns/op, 0 al/op | 72.2 ± 0.2 ns/op, 1 al/op |
| Type-erased | 36.4 ± 0.1 ns/op, 0 al/op | 72.1 ± 0.0 ns/op, 1 al/op |
| Synchronous | 1.0 ± 0.2 ns/op, 0 al/op | 19.0 ± 0.0 ns/op, 0 al/op |
Note: bex::task's await_transform calls the sender's as_awaitable member directly when available, bypassing connect and start. Table 3's native sender column measures the as_awaitable path, not the full sender protocol.
| Stream Type | sender (native) | awaitable (bridge) |
|---|---|---|
| Native | 31.9 ± 0.0 ns/op, 0 al/op | 43.5 ± 0.1 ns/op, 1 al/op |
| Abstract | 55.2 ± 0.0 ns/op, 1 al/op | 43.4 ± 0.0 ns/op, 1 al/op |
| Type-erased | 55.2 ± 0.0 ns/op, 1 al/op | 48.7 ± 0.1 ns/op, 1 al/op |
| Synchronous | 1.0 ± 0.2 ns/op, 0 al/op | 2.9 ± 0.2 ns/op, 0 al/op |
The full formatted report with detailed analysis is here: https://gist.github.com/sgerbino/2a64990fb221f6706197325c03e29a5e
Native performance is equivalent. Both models achieve ~31–34 ns/op with zero allocations when consuming their native I/O type on a concrete stream. There is no inherent speed advantage to either model at the baseline.
Type erasure costs diverge. capy::any_read_stream adds ~5 ns/op and zero allocations. The awaitable is preallocated at stream construction and reused across every read_some call. This is possible because await_suspend takes a type-erased coroutine_handle<> — the consumer type is already erased, so the awaitable's size is known at construction time. The sender equivalents add ~21–23 ns/op and one allocation per operation. The sender's connect(receiver) produces an op_state whose type depends on both the sender and the receiver. Since either may be erased, the operation state must be heap-allocated.
Bridges are competitive. Both bridges add 11–17 ns for native streams with zero bridge allocations. The allocations visible in the bridged columns come from the target model's own machinery (type-erased connect, executor adapter posting), not from the bridges themselves.
std::execution provides compile-time sender composition, structured concurrency guarantees, and a customization point model that enables heterogeneous dispatch. These are real achievements for real domains — GPU dispatch, work-graph pipelines, heterogeneous execution. Coroutines serve a different domain. They cannot express compile-time work graphs or target heterogeneous dispatch. What they do is serial byte-oriented I/O — reads, writes, timers, DNS lookups, TLS handshakes — the work that networked applications spend most of their time on.
| Feature | IoAwaitable | sender/receiver |
|---|---|---|
| Native concrete performance | ~31 ns/op, 0 al/op | ~32–34 ns/op, 0 al/op |
| Type erasure cost | +5 ns/op, 0 al/op | +21–23 ns/op, 1 al/op |
| Type erasure mechanism | preallocated awaitable | heap-allocated op_state |
| Why erasure allocates | it does not | op_state depends on sender AND receiver types |
| Synchronous completion | ~1 ns/op via symmetric transfer | ~2.6 ns/op via trampoline |
| Looping | native for loop | requires repeat_until + trampoline |
| Bridge to other model (native) | ~17 ns/op, 0 al/op | ~12 ns/op, 1 al/op |
| Bridge to other model (erased) | ~36 ns/op, 1 al/op | ~12 ns/op, 1 al/op |
r/cpp • u/emilios_tassios • Apr 10 '26
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 perform rigorous performance analysis on HPX applications using Intel VTune Profiler, detailing how this tool can be used to identify true bottlenecks down to the source line where standard software profilers often fall short. We focus on the configuration of CMake for VTune compatibility and the execution of the Hotspots collector, demonstrating the interpretation of profiling data through a practical analysis of a parallel sorting algorithm. The tutorial details the process of diagnosing common concurrency issues, utilizing VTune's GUI to uncover over-decomposition, microscopic task granularity, and idle threads, ensuring that applications are executing efficiently rather than thrashing the system. This provides a clear introduction to evaluating HPX's lightweight tasking system, culminating in actionable insights, where we illustrate how to seamlessly resolve performance flaws while harnessing the full potential of modern parallel hardware.
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 • u/_bijan_ • Apr 10 '26
If you’re not already familiar with Daniel Lemire, he is a well-known performance-focused researcher and the author of widely used libraries such as simdjson.
He recently published a concise overview of the evolution of the C and C++ programming languages:
https://lemire.me/blog/2026/04/09/a-brief-history-of-c-c-programming-languages/
It’s a worthwhile read for anyone interested in the historical context and development of systems programming languages.
r/cpp • u/According_Leopard_80 • Apr 09 '26
r/cpp • u/claimred • Apr 09 '26
Some non trivial cpp quiz style questions
r/cpp • u/LegalizeAdulthood • Apr 09 '26
Utah C++ Programmers has released a new video Managing Versions Programmatically with LibGit2 with sample code.
Lots of applications have configuration files and even user data files where it would be useful to track changes to those files with a version control system that was integrated into the application.
The git version control system is available for integration into applications as a library.
This month, Richard Thomson will guide us through a simple application that integrates git to track changes to an edited text file.
r/cpp • u/claimred • Apr 09 '26
I was looking for a new networking layer foundation for a few of my projects, stumbled on beast2 library which looks brand new, based on C++20 coroutines. I used boost.beast in the past which was great. Here's the link https://github.com/cppalliance/beast2. I also considered std::execution since it seems to be the way to go forward, accepted in C++26.
Now, what got me wondering is this paragraph
The C++26 std::execution API offers a different model, designed to support heterogenous computing. Our research indicates it optimizes for the wrong constraints: TCP servers don't run on GPUs. Networking demands zero-allocation steady-state, type erasure without indirection, and ABI stability across (e.g.) SSL implementations. C++26 delivers things that networking doesn't need, and none of the things that networking does need.
Now I'm lost a bit, does that mean std::execution is not the way to go for networking? Does anyone have any insights on cppalliance research on the matter?
r/cpp • u/TheRavagerSw • Apr 09 '26
Why pkgconf or cmake package or CPS isn't officially endorsed by the committee?
Can't cmake or meson guys, who go to meetings and conferences pressure the higher ups to get something accepted?
Multiple build systems are ok, multiple package formats are not. Why no one solves this issue?
r/cpp • u/JanWilczek • Apr 09 '26
Official JUCE C++ framework course and DSP Pro course creator here 👋 On April 14 and 28, I am running an audio-focused workshop as part of the C++ Online 2026 conference.
In the workshop, you will learn:
You can sign up here: https://cpponline.uk/workshop/jumpstart-to-cpp-in-audio/
If you're unsure if it's for you, I've given an introductory talk on the workshop material during the conference, which you can check out for free: https://youtu.be/IBLRv55qChw?si=hYDzZGdpTi4gz5dP
I'd also be happy to answer your questions regarding the workshop in this post 🙂
r/cpp • u/pavel_v • Apr 08 '26
r/cpp • u/Krystian-Piekos • Apr 08 '26
How to implement hash for custom classes in C++26.
We replaced SereneDB's AVX2 gather intrinsics with pure C++ and it actually beat intrinsics on x86_64.
The trick is combining сlang's auto-vectorization for dense data with #pragma unroll to let out-of-order execution handle sparse data. The post covers the assembly breakdown and some compiler traps that can make your code slower.
Happy to answer any questions below!
If you enjoy C++ systems optimization star us we appreciate your support!
r/cpp • u/igaztanaga • Apr 07 '26
I put together a comparison of std::deque internals across libc++, libstdc++, MSVC STL, and boost::container::deque (Boost 1.90). The article looks at the internal data structures, member layouts, sizeof(deque), and includes some benchmarks on common operations.
Boost 1.90 shipped a complete rewrite of its deque — the old SGI-derived layout was replaced with a more compact design (32 bytes vs the previous 80). The article digs into what changed, how the new implementation compares to the three standard library implementations, and how much block size alone affects performance across all of them.
https://boostedcpp.net/2026/03/30/deque/
Note: thanks to the info provided by u/HowardHinnant, I've update the article with additional info about the noexcept-ness of default and move constructors across implementations.