r/cpp • u/pavel_v • May 03 '26
r/cpp • u/BgA_stan • May 03 '26
When to actually use a set
dubeykartikay.comreposted with a different title, as i got feedback the previous title was clickbait
Post examples of using reflections in your projects
What the title says. I just want to see what interesting things people are using reflection for now that its in gcc. Thanks.
r/cpp • u/Financial_Travel_543 • May 03 '26
oo-alloc: i made a comprehensive learning resource for allocators in C++
hi!
i made a memory allocation library/learning resource. i wanted to learn more about them and i couldn't find one comprehensive source of knowledge, so i decided that i'll make one of my own:].
it currently has these basic allocator types: arena (linear), stack, pool, free list, free tree, tracking, buddy, slab.
i gave my best to describe everything clearly in the readme, also added svg diagrams (written in Typst, btw). i plan to implement a bucket/size-segregated free list allocator as well.
hoping anyone will find this resource useful!
https://github.com/nihiL7331/oo-alloc
I made C++ coding problems where you build things like a mini Redis or a tiny interpreter — looking for feedback
I’ve been building a small platform with coding problems that are more “systems-style” rather than typical algorithm exercises.
The idea is to practice by building simplified versions of real components, but still in a problem format (input/output + tests).
Some examples:
- implement a Redis-like server (TCP + protocol parsing)
- build a tiny interpreter
- create a virtual filesystem
- write an expression evaluator
The problems are:
- runnable directly in the browser (no setup)
- open-ended (you decide design/architecture)
- supporting multi-file submissions
I’m trying to keep them doable in a few hours, not huge multi-day projects.
I’m curious what people here think:
- does this kind of problem feel useful for improving practical C++ skills?
- or would you prefer something more guided / closer to full projects?
Still early, so any feedback would be really helpful.
Link: https://elitecode.pro/
r/cpp • u/javascript • May 02 '26
Does anyone maintain an impl of the Chandler Carruth map API?
Lightning Talk (C++Now 2019, 8min): https://youtube.com/watch?v=kye4aD-KvTU
In 2019, Chandler presented the above talk describing a C++ map API. It's not compatible with the standard map types, but for greenfield projects I think it's an excellent choice.
I've considered implementing it myself, but hash tables are very subtle and finicky. I'd rather rely on a robust implementation.
Abseil has some excellent hash tables, but to my knowledge they do not support the small size/small buffer optimization. Chandler's hypothetical API does. Would be great to have the SIMD probing algorithm from Abseil implemented for an SSO map type.
Mathieu Ropert: The Performance Mindset
youtu.beSoftware performance doesn't happen by accident, nor can it be an afterthought.
This talk illustrates this idea through the story of a 2x performance patch for a game, made as a side project, by explaining not just what was done, but, more importantly, how and why it was possible to achieve in the first place.
r/cpp • u/User_Deprecated • May 02 '26
CppCon CppCon 2025: Can Standard C++ Replace CUDA for GPU Acceleration? - Elmar Westphal
youtube.comr/cpp • u/SuperV1234 • May 01 '26
stackless coroutines for gamedev in ~200 lines of C++
vittorioromeo.comr/cpp • u/Separate-Summer-6027 • May 01 '26
The STL for Geometry: Thirty-Year Evolution of C++ Libraries
polydera.comVTK, CGAL, libigl, MeshLib, and what comes next. What the STL philosophy of separating algorithms from data looks like when applied to geometry: semantic ranges, composable policies, and parallel algorithms that operate on them.
In 1994, Alexander Stepanov changed C++ by proving that algorithms should not belong to data structures. If you have m algorithms and n containers, you don't need m × n implementations. You need m + n. The iterator was the bridge. A single sort() works on a vector, a deque, or a raw int*.
This shaped what idiomatic C++ feels like. Yet the geometry processing libraries developed since have not quite felt that way.
r/cpp • u/ContDiArco • May 01 '26
External Polymorphism in C++26
While developing our Type Erasure library Any++ for C++23, we had to resort to a preprocessor-based EDSL to eliminate the boilerplate.
By studying the "C++26 Reflection Proposals," I was constantly searching for a way to replace this preprocessor programming.
Implementing Type Erasure requires three components:
-
A "V-Table" for indirecting function calls.
-
A "Facade" for the ergonomic connection between the data and the "V-Table."
-
An "Adapter" to connect the functions of the "V-Table" to the specific type.
It suffices to describe one of these components. The other two can then be generated automatically.
One way to do this with C++26 is to specify in code the default adapter and generate the V-table and facade.
C++26 allows you to generate a class using define_aggregate.
The key is that the class can only contain data members.
However, since a data member can have an operator(), member functions can also be simulated this way.
These data members can be specified so that they don't occupy any memory. This allows you to access the enclosing class in the operator() and use the information it manages (the V-table and the data reference).
Interestingly, this method also enables static dispatch with an elegant interface.
To coincide with the GCC16 release and its excellent reflection implementation, I've sketched out such an API:
;
void
;
;
;
;
;
int
This is, of course, just a rough outline. The real value of a type erasure library lies in providing additional runtime capabilities (downcast, crosscast), lifetime mechanisms (shared, unique, value, etc.), and constant correctness.
Any++ provides all of this. As soon as Clang and MSVC also offer reflection, I will implement the presentated technique there.
For now, I have to thank the wizards who created this technical marvel: "C++ compile-time reflection"!
r/cpp • u/American_Streamer • May 01 '26
Juan Alday of Citadel Securities: Why C++ Wins in Finance (April 28th, 2026)
youtube.comIn markets, performance is defined by consistency under pressure. Hear Juan Alday share why C++ continues to deliver.
r/cpp • u/emilios_tassios • May 01 '26
CSC4700: Parallel C++ for Scientific Applications
youtube.comAs we conclude our posting cycle for this series, we invite you to explore the complete collection of topics.
In this comprehensive playlist, Dr. Hartmut Kaiser focuses on the fundamental principles and advanced techniques of parallel C++ for scientific computing. The course highlights essential foundational concepts by exploring the intrinsic relationship between modern hardware architectures and software design, setting the stage for developing highly efficient, scalable scientific applications.
A core discussion demonstrates how to utilize the C++ Standard Library alongside the HPX framework as a unified solution for orchestrating parallelism, specifically addressing the practical challenges of cache optimization, data locality, and multi-node execution. Finally, critical strategies for linearizing complex mathematical models are explored, offering a comprehensive approach to maximizing performance across diverse high-performance computing environments.
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/TheHPXProject/hpx
r/cpp • u/BloodyBBenzene • Apr 30 '26
I made a super fast CNN library for C++20 from scratch.
I was exploring Convolutional Neural Networks (CNNs) in more depth and I had an interesting idea of making a dependency free, header only cnn library for C++20.
I did some research and found out about tiny-dnn which is a cnn library for c++14, super fast but the developers stopped updating it back in 2016, so I decided to take on a challenge to make my own CNN library from scratch for c+ +20 with extreme performance tuning for CPU, and I did achieve close to what I was expecting.
I benchmarked with "pytorch" and the results were good enough to post, I have documented about the library here along with the benchmark results. At some instances it outperformed pytorch and I was shocked too.
Documentation- "https://kunwarprabhat.github.io/MetalNet_Documentation/
To get a rough idea on how fast is my engine it goes 97.51% accuracy on mnist dataset in just 25 seconds of training with a throughput of 2k+ images / second.
processor - Ryzen 7 5800H mobile
For overview -
My engine uses DAG layout
It has Zero Allocation
Multithreading Support
L1/L2 Cache Optimization
and a lot of internal stuffs going on, here is the repository link-
"https://github.com/KunwarPrabhat/CustomCNN"
My engine is still in its early stage so there are alot of things that can be fixed I need more devlopers to contribute if they're interested in it :))
Edit : By zero allocation, I meant to say my engine pre allocates memory so it doesn't have to ask OS for allocation during inference. I am not saying it doesn't use memory at all I am saying it doesn't allocate during runtime, it's basically a pre-allocation.
r/cpp • u/AccordingWarthog • Apr 30 '26
GCC 16.1 released with many new C++26/23 features, C++20 now the default stable language version
gcc.gnu.orgC++ has better libraries
I just want to know, where are those better libraries?
I have 5 years of c++ experience, my initial job was straight forward: the codebase already existed, I don't have much responsibility etc, then my second job was terrifying Asio? I think it shall be named AssIo, corotines? If multi-threaded is a footgun then coroutines are a missile, performance? Do I have the whole day optimizing aliasing and tuning for a certain tool chain. That said as the last try I just want to ask here on Reddit the worst place to get advice.
Was c++ a wrong choice for a high load backend (quic, capnp, libav, postgres)?
r/cpp • u/pavel_v • Apr 30 '26
C++26: string and string_view improvements
sandordargo.comr/cpp • u/javascript • Apr 30 '26
Is anyone still using the CTRE library in 2026?
Back in 2018 an engineer/committee member made a splash by introducing CTRE, Compile Time Regular Expressions.
It was implemented using type aliases instead of constexpr function calls meaning it was easy to implement in C++11. Very impressive stuff.
It also gave you a nicer callsite spelling in C++20 leveraging generalized non-type template parameter passing.
I'm curious if anyone is still using it. If no, why not? I'd love to hear!
r/cpp • u/TheCrush0r • Apr 30 '26
Safe Optimistic Lock Coupling
databasearchitects.blogspot.comr/cpp • u/Kabra___kiiiiiiiid • Apr 30 '26
Some theory and practice of alignment in C++ (guide part 3).
pvs-studio.comIf you haven’t seen parts 1 and 2 yet, they go over the basics and ordinary inheritance.
This one is about what happens when you add virtual to a class (spoiler: it can seriously mess with the whole memory layout)
r/cpp • u/DogCrapNetwork • Apr 30 '26