r/cpp • u/User_Deprecated • Jun 15 '26
r/cpp • u/TheRavagerSw • Jun 14 '26
Projects being in "Show and Tell" is bad.
Because of this, nearly all posts are just conference links and blog links. Projects deserve their own post and are the source of actual fun discussion. I propose that the Show and Tell rule be removed, but Show and Tell post can remain if a project that lame appears.
r/cpp • u/Specific-Housing905 • Jun 14 '26
C++ RVO: Return Value Optimization for Performance in Bloomberg C++ Codebases - Michelle Fae D'Souza
youtube.comReturn Value Optimization for Performance in Bloomberg C++ Codebases
r/cpp • u/TrnS_TrA • Jun 14 '26
Repo of utilities written with C++ reflection
I started exploring C++26's static reflection, and I'm putting together a repo with utilities written with it First utility I have, is std::visit, but for C unions (with some small constraints to avoid UB ofc) I'd love to hear any suggestions and feedback! Repo
r/cpp • u/BrilliantWishbone2 • Jun 14 '26
cppman.nvim: Browse C++ docs from inside Neovim
I hope it's okay that I post this here. If not, just let me know and I'll remove it.
I made a small Neovim plugin called cppman.nvim for browsing C++ reference docs directly inside Neovim.
I use it myself quite a bit, so I thought I'd share it in case anyone else finds it useful, or has ideas for improvements.
It adds :CPPMan, uses cppman's local index, and opens the docs in a floating buffer. It also supports both fzf-lua and snacks.nvim.
I tried to keep it lightweight and not too opinionated.
Repo: https://github.com/simonwinther/cppman.nvim
Stars are appreciated if you find it useful.
r/cpp • u/Tall-Assignment1349 • Jun 15 '26
LLMs with C and C++ - switch from HFT to AI lab
I'm a senior C++ dev recently started working with a neolab (who works with anthropic). Thought I would write some of observations i made.
- I had experimented with LLMs for a while before making the switch. LLMs fail a lot on C and C++ due to harder nature and powerful nature of language.
- Talking purely from benchmarks, languages like python and JS (the vibecoder's first language) have very hard benchmarks - think fixing actual bug that touches 3 different modules from scratch with access to tools like grep, cat and python3 executer.
- Whereas, benchmarks for C and C++ are at basic QA style questions. I have added a task from benchmark, which fable 5 could not solve.
- LLMs do not have understanding of latest ISO standards - for some reasons it switches to C++17 again and again
- LLMs are trash at template metaprogramming. Try debugging CRTP type of errors.
Looking at the efforts and progress, I am still not sure if we will see LLMs writing MRs to linux kernel. The approach they used for vibecoding languages do not care about memory safety, thread safety and performance much. It would be interesting to see the space evolve.
PS: a example from benchmark
PS2: i'm not associated with benchmark. they say the code is taken from real github issues.
Observe the following faulty CPP code snippet and error type list. Your task is to select the error type of the code based on the error list provided.
You only need to answer error type. Do not write anything else in your response.
For example, if the code snippet is missing a semicolon, Your output should be 'missing_colons'.
faulty code:
```cpp
#include <bits/stdc++.h>
int countPermutations(int n, int k, int qq[])
{
const int N = 505, P = 998244353;
int *q = new int[n + 10];
int m, dp[N][N], jc[N], f[N], ans;
memset(q, 0, sizeof(int) * (n + 1));
memset(dp, 0, sizeof(dp));
memset(jc, 0, sizeof(jc));
memset(f, 0, sizeof(f));
ans = 0;
for (int i = 1; i <= n; i++)
q[i] = qq[i - 1];
dp[0][0] = f[0] = 1;
for (int i = jc[0] = 1; i <= n; i++)
jc[i] = 1LL * jc[i - 1] * i % P;
for (int i = 1; i <= n; i++)
{
f[i] = jc[i];
for (int j = 1; j < i; j++)
f[i] = (f[i] + P - 1LL * f[j] * jc[i - j] % P) % P;
}
for (int i = 1; i <= n; i++)
{
for (int j = 0; j < i; j++)
for (int k = 1; k <= n; k++)
dp[i][k] = (dp[i][k] + dp[j][k - 1] * 1LL * f[i - j] % P) % P;
}
m = 0;
for (int i = 1; i <= n; i++)
if (q[i] > q[i + 1])
{
m = i;
break;
}
if (m == n)
{
for (int i = k; i <= n; i++)
ans = (ans + dp[n][i]) % P;
}
else
{
for (int i = m + 1; i <= n; i++)
{
if (i != m + 1 && (q[i - 1] > q[i] || q[i] < q[m]))
break;
int c = k + i - n - 1;
if (c >= 0)
ans = (ans + dp[m][c] * 1LL * jc[i - m - 1] % P) % P;
}
}
return ans;
}
```
error list:
['Delayed Execution', 'Improper HTML structure', 'Missing $', 'Missing mut', 'Misused := and =', 'Misused === and ==', 'Misused =>', 'Misused Macro Definition', 'Misused Spread Operator', 'Misused begin/end', 'Misused match', 'Misused var and val', 'Unused Variable', 'algorithm_error', 'condition_error', 'double_bug', 'faulty_indexing', 'function_error', 'html_unclosed_label', 'html_value_error', 'html_wrong_label', 'illegal_comment', 'illegal_indentation', 'illegal_keyword', 'illegal_separation', 'json_content_error', 'json_digital_leader_is_0', 'json_duplicate keys', 'json_struct_error', 'markdown_content_error', 'markdown_title_error', 'markdown_unclosed_error', 'missing_backtick', 'missing_colons', 'misused ==and=', 'misused templte', 'misused_let', 'operation_error', 'Pointer error', 'quadruple_bug', 'triple_bug', 'type_error', 'unclosed_parentheses', 'unclosed_string', 'undefined_methods', 'undefined_objects', 'variable_error']r/cpp • u/LegalizeAdulthood • Jun 14 '26
Vcpkg Binary Caching on GitHub Finally Made Easy
github.comFor a long time I've struggled with vcpkg binary caching on my github CI jobs. There's a variety of critical information buried deep across various documentation pages that all interact when you attempt to use binary caching on a github repository with public github runners and CI workflows. This weekend I finally got it all figured out and debugged for my public repositories and realized that the steps needed to make everything work are non-obvious and intricate. This is the perfect thing for packaging up as a github workflow action for reuse across repositories.
This project consists of two actions:
- one that does all the setup
- one that analyzes your build log
This gives you details on how your build interacted with vcpkg binary caching to report problems. Usually the build summary is all you need to understand the cache: cold seed, warm hit, partial hit, etc. Should you need to dig in deeper to debug a weird situation there are two knobs -- debug and trace -- that can give you enough detail on everything that happened so you can sort out problems without having to manually add logging to your workflow.
It may still be necessary to manually adjust the permissions on individual packages that are shared across repositories on your account. Unfortunately there's no way to manipulate the permissions programmatically. The analyze action smooths this out by giving you a table of packages that had permission issues, with links to each package's permission page on github. From there you can quickly adjust permissions as needed without having to hunt through a long list of packages on your account.
r/cpp • u/mateusz_pusz • Jun 13 '26
Report from the Brno 2026 ISO C++ Committee meeting - mp-units
mpusz.github.ioBack from the Brno ISO C++ meeting, the first of the C++29 cycle. My report covers two things: the highlights voted into the C++29 working draft at the closing plenary, and the current status of the quantities and units effort.
From the plenary, the big one: C++29 gained two annexes (P3596) that catalog every case of undefined behavior and IFNDR in one place. You can't systematically reduce, diagnose, or tool against UB you haven't first enumerated, so this is foundational safety work.
Two smaller fixes will also improve how quantities print: corrected std::format floating-point defaults (P3505) and deprecating 1-byte integer types streaming as characters in iostreams (P3154).
On my own papers:
- P3045 (quantities and units): SG6 forwarded it to LEWG. The design now heads to the evolution group in Brazil.
- P4185 (absolute quantities): SG6 encouraged the new absolute-quantity abstraction, a third kind alongside
quantityandquantity_point, and asked to split range-validated quantity points into their own paper. Both are targeted for mp-units V3. - P3094 (
std::basic_fixed_string): the building block that lets mp-units encode unit and dimension symbols in the type system. LEWG gave weak consensus to make it mutable, against my non-mutating proposal, so I'm pursuing a minimal non-constoperator[]rather than a redesign. - SG20 (education) reviewed the teaching material, and the chair called it some of the best teaching sections he's seen.
Please check the mp-units blog for a full report.
r/cpp • u/Longjumping_Fig_9044 • Jun 15 '26
Looking for collaborators to build an OpenGL engine in C++
I'm currently developing a small OpenGL engine in C++ as a personal learning project and foundation for future graphics and simulation applications.
The project is open source:
https://github.com/HG9032/OpenGLengine
I'm looking for people who are interested in computer graphics, OpenGL, game engines, rendering, or C++ development and would like to contribute, learn together, or discuss ideas.
The engine currently includes:
- Window management (GLFW)
- Shader management
- Mesh rendering
- Transform system
- Basic rendering pipeline
Planned features:
- Camera system
- Scene management
- Materials and textures
- STL model loading
- Lighting
- Thermal simulation visualization
Whether you're experienced or just learning OpenGL, feel free to reach out if you'd like to collaborate.
r/cpp • u/germandiago • Jun 13 '26
Crazy idea: reducing function coloring in function templates and enabling reuse, is it possible by caller-injected marker?
I was reading a paper about resumable functions short ago and I wonder if a language extendion would be possible that would work the following way:
// Poor man's syntax
std::copy_if(myrange, co_awaitable [](...) { co_await ... });How would it work? Taking advantage that templates are code to be generated, at the place where the function is called, the compiler would generate a co_await for the function, making it reusable.
r/cpp • u/Strong_Technician416 • Jun 13 '26
Recommendations for brushing up on modern cpp (ideally C++ 20)
Starting my first job as a new grad in the aerospace sector and need to brush up on modern C++ and looking for solid resources to understand the current fundamentals of the language. Thanks in advance!
r/cpp • u/janwas_ • Jun 12 '26
Comparing std::simd with Highway
From TL of Highway, some thoughts on pros and cons of std::simd by comparison:
https://github.com/google/highway/blob/master/g3doc/std_simd_comparison.md
Happy to discuss.
r/cpp • u/no-bugs • Jun 12 '26
Efficient C++ Programming on Modern 64-bit CPUs, part 1 of Chapter 4
Well, I'm starting to publish (VERY DRAFT) Chapters from my (and Dmytro Ivanchykhin's) upcoming book, "Efficient C++ Programming for Modern 64-bit CPUs". Comments are extremely welcome (as before, we're committed to fixing all the issues highlighted in comments).
The first installment is the first part of Chapter 4: https://6it.dev/blog/on-cpu-physics-and-cpu-cycles-80730
In Vol. 1, the most interesting will probably be Chapter 9, with about 200 (sic!) practical de-pessimization hints.
Beware: this is not a book on optimizations (though some techniques will be covered in Appendixes A and B in Vol. 2) - this is a book on de-pessimizations; for optimizations - please refer to the excellent book by Denis Bakhvalov (though we're sure that de-pessimizations should be seen as a prerequisite for optimizations š).
Bracing for impact...
r/cpp • u/Standard-Cow-4126 • Jun 12 '26
What would make you consider using a new sorting algo?
I've been working on a parallel integer sorting algorithm and benchmarking it against ipso, parlay's integer sort (radix ) etc.
For people who work on databases, analytics systems, HPC, compilers, or other performance-sensitive software, what feature would you need before seriously considering a new sorting implementation?
Examples:
- Better throughput?
- Better scaling? (on both key size and input size )
- Lower memory overhead?
- NUMA results?
- ARM benchmarks?
- Stable sorting?
- Key-value sorting?
- Something else?
My algo currently aims to fix the scaling issue with radix , it gets slower if you increase the key size. And providing support for 128 bits , as most parallel radix implementation only support 64 bits in a single pass (for 128 bits or higher you need to multiple stable passes.
I'd especially like to hear from people who have actually deployed or evaluated sorting implementations in production systems.
Basically the end goal is to build something that is actually useful to someone.
r/cpp • u/ericbrumer • Jun 11 '26
MSVC Build Tools Preview updates - June 2026 - C++ Team Blog
devblogs.microsoft.comHi, one of the MSVC dev leads here.
Here's what's new in the MSVC Build Tools Preview since mid-May.
Instructions to install & use the latest preview bits are at https://aka.ms/msvc/preview.
If you need a primer on MSVC versioning, see https://www.reddit.com/r/cpp/comments/1smfgdu/demystifying_msvc_versioning_for_1450_later/ or https://learn.microsoft.com/en-us/cpp/overview/compiler-versions , but essentially:
- 14.52.* is the latest preview, updated regularly with bits from our development branch.
- 14.51.* is the latest default toolset, which is in support through February 2027.
- 14.50.* & older releases are still available as side-by-side installation components.
r/cpp • u/C_Sorcerer • Jun 11 '26
How to stop being absolutely psychotically obsessed with making ābeautifulā code
I love C++. I love C as well. I have since the day I touched it in around 7th grade. Now Iāve graduated college and still love it all these years later and while my GitHub is FULL of projects, almost all of them are unfinished because of my obsessive tendencies. Just for an example, I have a 3D graphics renderer which I made with OpenGL which I have redone 16 TIMES and only once did I actually finish it and Iām still not happy with it compared to others programs. Iāve done the same with a Vulkan renderer which is unfinished and a Gameboy emulator which is also unfinished, as well as many others.
Iām dealing with the same thing now as I took a break after school from projects to chill and now started a new project which is a raycaster style game with SDL2, and at first all was well. That didnāt last long. Just from making a clean interface for a Point or a Vector is driving me insane, and the map layout as well as many many other things. I swear Iāve already rewritten half of it about 4 times now. And i canāt stand mixing C code (I LOVE C but not when itās near C++ code) and C++ code and with SDL2 having many C-like paradigms, it is driving me genuinely insane. It gets so bad that I just get angry and stop programming and next thing I know Iām in another 2 week slump.
I never really have this problem with C as it doesnāt have as many ways to do things, so Iāve finished quite a few projects in C such as a few kernel drivers and a graphics engine. But I would really like to hone my skills in C++ a little more since it seems that in the graphics industry C++ is the de facto standard. The thing isnt that I donāt know the language either; I just get so in my head about it.
I really want to get at least one more C++ project finished before I begin seriously applying to more jobs because I want to show off my skill in it from all these years of using it. But at this point Iām beginning to just think I should stick to C as Iām just too neurotic about things.
What are your opinions or methods to get out of this overly obsessive perfectionist mindset and just make a project?
r/cpp • u/Fola_Tau • Jun 12 '26
Tau Parser - a parsing library for C++ for Boolean grammars (CFG + conjunction + negation)
https://github.com/IDNI/parser
Tau Parser handles Boolean grammars: context-free, conjunction and negation. You can write something like identifier & ~keyword directly in the grammar to match any identifier that isn't a reserved word. No separate lexer hack, no keyword table living in your host code.
The grammar format (TGF) is EBNF-like and readable. Here's keyword-exclusion in practice:
identifier => (alpha | '_') (alnum | '_')* & ~keyword.
keyword => "let" | "if" | "else" | "while" | "fn" | "return".- Earley-based, so left recursion works, no grammar refactoring.
- Handles ambiguity natively (full parse forest available), but auto-disambiguation gives you a single tree by default with zero configuration. You can switch it off per-nonterminal when you actually want the alternatives.
Header-only after codegen. Run
tgf calc.tgf gen, include the generated header, and parse:auto r = calc_parser::instance().parse(input, len); if (r.found) r.get_tree()->to_print(std::cout);
- The
tgfCLI also ships an interactive REPL and a test runner for.tgf.testfiles with tree-shape assertions. - Tree shaping (
@trim, u/inline) lets you strip whitespace/punctuation and collapse wrapper nodes so you get a clean AST. - Platform parity across Linux, macOS, Windows (mingw-w64), and WASM/Emscripten.
Boolean grammars can also express some things beyond context-free e.g. requiring two productions to derive the same string, or asserting a span does not match a production ā so certain constraints that'd normally need a separate validation pass live in the grammar instead.
Status: alpha, under active development toward 1.0.
r/cpp • u/germandiago • Jun 11 '26
Still amazed every time I read this paper. What pros and cons do you think it would have against C++20 coroutines?
open-std.orgJust was reading again this. What I like is the core idea that it looks much closer to concepts I understand in C++ (mainly function objects) instead of all the dance for promise_type/suspend/await_transform, etc.
r/cpp • u/meetingcpp • Jun 11 '26
Meeting C++ The voting on the talks for Meeting C++ 2026 has begun!
meetingcpp.comr/cpp • u/LegalizeAdulthood • Jun 11 '26
A Codex Experience Report
youtube.comAI this, AI that, it seems it's all anyone can talk about these days. But is it any good? Curmudgeons say that the generated code is garbage and that "AI can't do it". Are they right? The hype train has left the station and is saying engineers are going to be unemployed in the next 18 months. Are they right?
This month, Richard Thomson will give us an experience report on using Codex for improvements he's been making to his open source fractal renderer, Iterated Dynamics and the associated projects Formula Compiler, ParAnimator and par-beatdown.
Is it the end of the world or is the future so bright I gotta wear shades?
r/cpp • u/0D2-faf • Jun 10 '26
How far can C++20 coroutines go in asynchronous networking? My experience from the runtime to a Redis client library
Hi all! I've been playing with C++ coroutines for a few months now.
At first, I started building an async runtime based on io_uring to better understand the model of C++ stackless coroutines, and I was amazed by writing asynchronous code that feels just as clean and readable as other languages. Soon, I want to go beyond that and see how far the coroutine model can go in simplifying asynchronous programming. So, I decided to build an asynchronous Redis client library on top of my runtime.
During building the Redis client library, I quickly realized that my runtime was missing some utilities for complex workflows, such as the when_all and when_any combinators. But this was resolved quickly under the strong expressive ability of C++ coroutine model, andĀ I finally achieved the simple interface as exactly what I am expecting like this:
auto [_1, _2, _3, exec_res] = co_await redis.multi()
.set("user:{1001}", "val1")
.set("item:{1001}", val2)
.exec();I've been experimenting with different task types via promise_type throughout this process, and gained a much deeper understanding of the mechanics behind Awaiter and std::coroutine_handle<>. So Iām now convinced that the current C++ coroutine model has greatly reduced the complexity of asynchronous programming, except for theā¦ā¦
Cancellation
Cancel a single IO such as the recv/send seems to be straightforward as the runtime already provides that function. However, things get tricky when you try to extend this ability to a task level. For instance:
Considering Task A is awaiting B or C, and C will await D (A->B/C->D)
In this case, registering every single IO in the async call tree to cancel manually will be a nightmare, we might just want to call A.cancel() or derive a canceltoken from A instead of checking what exactly single IO is in D. Also, The cancellation of C might not affect the B but do cancel the D.
std::execution describes the stoppable_token and set_stopped() to achieve this goal, while it requires very careful implementation of each receiver to check the stop token. The coroutine-based IO suggests that the token might be hidden within the promise_type,as long as the root suspended nodes remember to check if it is stopped and register its callback in the call chain with some tricks in `await_suspend` and `await_transform()` like:
template<class Promise>
bool await_suspend(std::coroutine_handle<Promise> h){
if constexpr( requires{ h.promise().hook(this); } ){
bool stopped = h.promise().hook(this);
if(stopped){ return false; }
}
}It is hard to tell which method is "better" because the cancellation itself is actually scenario-dependent and outside the language core, yet currently I am accepting the second method as it fits my coroutine-based runtime simply. For instance, image that you are awaiting commands to the Redis server, it is hard to give a good definition about the cancellation of that operation, as the TCP packets might already reach the server side.
So, in a word, you can achieve a lot with the C++20 coroutine model nowadays, but we still have a lot of open questions to resolve in the asynchronous programming.
My Repo if you are interested in.