C++ - Reddit
227 subscribers
48 photos
8 videos
25.3K links
Stay up-to-date with everything C++!
Content directly fetched from the subreddit just for you.

Join our group for discussions : @programminginc

Powered by : @r_channels
Download Telegram
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::copyif(myrange, coawaitable (...) { coawait ... });

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.




https://redd.it/1u4nyp5
@r_cpp
Spatial Canvas: a single-file C++/Win32/Direct3D 11 zoomable window manager that puts your live windows on an infinite canvas

I've been building a zoomable-UI (ZUI) window manager for Windows in C++ and

wanted to share the architecture, since the interesting part is how you keep

dozens of live windows rendering at once.



Each window is captured via Windows.Graphics.Capture (FreeThreaded frame pool,

poll-based, lock-free) into a persistent D3D11 texture, then drawn as a

1:1-pixel textured quad in world space on a borderless fullscreen swapchain.

Pan/zoom is just a camera transform. A D2D/DWrite overlay draws the rest:

title labels, a world-anchored dot grid, the minimap, docks.



The hard problem: if you move/hide windows off-screen to composite them, DWM

occlusion-throttles them and Windows.Graphics.Capture starts returning black

or stale frames. Your canvas fills with black tiles. So there is no input

simulation and no off-screen hiding. Instead, each window "parks" in a 2px

visible strip at the bottom of the primary monitor — 2px is enough that DWM

keeps compositing it, so the capture stays live, but it's hidden behind the

canvas. When you cross a zoom threshold (or double-click), the real HWND is

moved (SetWindowPos) onto its quad's screen rect and given focus; now you're

typing into the actual window, not a proxy. Pull back and it returns to the

strip. Two states per window: parked (live texture on the canvas) and

swapped-in (the real window).



Other bits:

\- Single translation unit (\~3300 lines, Canvas.cpp), entry RunCanvasApp().

\- Idle-throttled main loop (dirty flag + MsgWaitForMultipleObjectsEx) so it

doesn't burn the GPU when nothing changes.

\- Device-lost (TDR / sleep-wake) does a full D3D/D2D/WGC rebuild; an unhandled-

exception filter un-parks windows on crash so nothing is stranded in the strip.

\- Single 559 KB exe, statically linked — no .NET / VC redist.



A few things that bit me along the way:

\- IsBorderRequired(false) / the borderless-capture path black out capture on

some Windows builds — removed.

\- Content-sized CopySubresourceRegion + a drain-to-newest loop also produced

black tiles; a single TryGetNextFrame + full CopyResource is the proven path.

\- Added a cbuffer field the pixel shader reads, but bound the cbuffer only to

the vertex stage → every tile came out alpha=0 (invisible). If a stage reads

a cbuffer, bind it to that stage.



Repo + 30s demo: https://github.com/13auth/spatial-canvas



It's an early prototype and I'd genuinely appreciate critique on the capture/

compositing approach. (Heads-up: source-available but not OSS-licensed — happy

to explain the reasoning in the comments.)

https://redd.it/1u52eim
@r_cpp
C++ lifetimes. Is there an alternative way? Hylo subscripts achieve controlled lifetimes without viral annotations
https://hylo-lang.org/docs/user/language-tour/subscripts/

https://redd.it/1u5ffmc
@r_cpp
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

https://redd.it/1u5j36c
@r_cpp
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

https://redd.it/1u5pvuq
@r_cpp
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.

https://redd.it/1u5x86n
@r_cpp
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.

​

https://github.com/HG9032/OpenGLengine

https://redd.it/1u6979x
@r_cpp
New C++ Conference Videos Released This Month - June 2026 (Updated to Include Videos Released 2026-06-08 - 2026-06-14)

**C++Online**

2026-06-08 - 2026-06-14

* Monads Meet Mutexes - Arne Berger - [https://youtu.be/AisGDOoF82U](https://youtu.be/AisGDOoF82U)
* Lock-free Queues in the Multiverse of Madness - Dave Rowland - [https://youtu.be/eHmjkFdQl00](https://youtu.be/eHmjkFdQl00)

2026-06-01 - 2026-06-07

* Writing C++ Code is Challenging, Writing Performant C++ Code is Daunting - Dmitrii Radivonchik - [https://youtu.be/R2sm9mailuU](https://youtu.be/R2sm9mailuU)
* Case Study - Purging Undefined Behavior and Intel Assumptions in a Legacy Codebase - Roth Michaels - [https://youtu.be/H-dHTeSR\_n8](https://youtu.be/H-dHTeSR_n8)

**ADC**

2026-06-08 - 2026-06-14

* Low Latency Android Audio with improved CPU Performance - Phil Burk - [https://youtu.be/DtBrKEu0R0g](https://youtu.be/DtBrKEu0R0g)
* Linux as the Conductor - Driving Pre-Compiled Audio DSP Kernels on C7x for Real-Time Processing - Vishnu Pratap Singh - [https://youtu.be/Auq9WnHNtPo](https://youtu.be/Auq9WnHNtPo)
* Overview of Granular Synthesis - Avrosh Kumar - [https://youtu.be/QpBV24nWg2M](https://youtu.be/QpBV24nWg2M)
* The Agentic Symphony - Multi-Agent Collaboration for Emergent Musical Composition - Meera Sundar - [https://youtu.be/QMUXoImgTIA](https://youtu.be/QMUXoImgTIA)

2026-06-01 - 2026-06-07

* Beyond the DAW - Designing a Procedural Sequencer Powered by Music-Theory - Romy Dugue & Cecill Etheredge - [https://youtu.be/48sH4wQUDAs](https://youtu.be/48sH4wQUDAs)
* From DAW Users to Audio Developers - Teaching JUCE to Creative Minds - Milap Rane - [https://youtu.be/200UrugEanY](https://youtu.be/200UrugEanY)
* Music Design and Systems - Achieving Inaudibly Complex Systems in Video Games - Liam Peacock - [https://youtu.be/R6raBvCNsQo](https://youtu.be/R6raBvCNsQo)
* Developing for Avid’s Audio Ecosystem - Rob Majors - [https://youtu.be/91-7YWVKRE4](https://youtu.be/91-7YWVKRE4)

**CppCon**

2026-06-01 - 2026-06-07

* Lightning Talk: Navigating Code Reviews as a Code Author - Ben Deane - [https://youtu.be/zygtgvHp\_MM](https://youtu.be/zygtgvHp_MM)
* Lightning Talk: Eight Consteval Queens and Compile-Time Printing - Sagnik Bhattacharya - [https://youtu.be/gNPhJrXLiIs](https://youtu.be/gNPhJrXLiIs)
* Instrumenting the Stack: Strategies for End-to-end Sanitizer Adoption - Damien Buhl - [https://youtu.be/TSrymTXw5w8](https://youtu.be/TSrymTXw5w8)

https://redd.it/1u6ik24
@r_cpp
Cross-Language Data Types

https://ekxide.io/blog/cross-language-data-types

Have you ever thought about sharing data across language boundaries without serialization? This blog post highlights the challenges behind this endeavor and how they can be overcome. Note: I'm not the original author of the blog post, but since the author does not have a Reddit account, I post it on his behalf.

https://redd.it/1u6mrw8
@r_cpp
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=',