227
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
I built MrDocs, an open-source C++ reference doc generator on the Clang/LLVM AST. Looking for feedback.
I'm Alan de Freitas, the lead developer of MrDocs. It's an open-source documentation generator from the C++ Alliance, built on Clang/LLVM. It reads your code from the compiler's AST, so the reference matches what the code actually compiles to. We also presented [a session](https://cppcon2026.sched.com/event/2RT70/mrdocs-reliable-reference-documentation-for-c++-using-the-clang-ast) about it at cppcon this year.
I implemented the tool this way because we couldn’t come up with a workflow that understood modern C++ in our Boost libraries. Tools that parse partially tend to misrender or not render concepts, niebloids, SFINAE, overload sets, and deduction guides. MrDocs treats those as first-class:
* concept constraints and requires clauses preserved verbatim
* niebloids and function objects can be documented as callables
* SFINAE and concept overload sets kept together
* explicit, noexcept, and consteval specifiers captured
* types in detail or private namespaces rendered as implementation-defined
The presentation layer is completely encapsulated. Generators support HTML, AsciiDoc, XML, JSON, or any custom format like Markdown and LaTeX, without forking the tool or creating another post-processing workflow. You can also write extensions to apply project conventions to the corpus or define new generators for any use case. The documentation has lots of examples.
If you maintain reference docs for a library, I'd appreciate it if you gave it a run (or tell your favorite agent to) and reported back on whether it saves you time, both while writing docs and while reviewing them. First-hand numbers would be especially useful to me. Issues are also always welcome.
Site:[ https://www.mrdocs.com](https://www.mrdocs.com/)Repo:[ https://github.com/cppalliance/mrdocs](https://github.com/cppalliance/mrdocs)
Happy to answer questions in the comments.
https://redd.it/1wz3115
@r_cpp
How I speed up my overall build times by 4x and incremental builds by 9x for test builds
* I used faster tools:
* I switched from lld to mold optimized it mimalloc + pgo + lto + bolt (1.2x-3x faster than system lld)
* I optimized clang with mimalloc + pgo + lto + bolt (1.8x-1.85x faster than system clang)
* I optimized clang-scan-deps with mimalloc + pgo + lto + bolt (4x faster than system scanner)
* I used dynamic linking(3x-4x overall, much larger if you are editing tests)
* I used prebuilt binaries via packages rather than vendoring my deps.(huge)
* I switched fully to C++ modules(Incremental compilation times are so fast link times dominate now)
https://redd.it/1wet7rn
@r_cpp
Jonas Persson: Making every byte count
https://youtu.be/GbwrztrY4kc
https://redd.it/1wf1l3o
@r_cpp
==2896379==
logger no timeout configured, using default 1000 ms
==2896379==
==2896379== HEAP SUMMARY:
==2896379== in use at exit: 0 bytes in 0 blocks
==2896379== total heap usage: 2 allocs, 2 frees, 74,752 bytes allocated
==2896379==
==2896379== All heap blocks were freed -- no leaks are possible
==2896379==
==2896379== For lists of detected and suppressed errors, rerun with: -s
==2896379== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
You can see Valgrind is complaining about an uninitialized variable created on the stack:
Uninitialised value was created by a stack allocation
The reason is that GCC handles the two cases with two different warnings. In the first example, value is uninitialized on every path, and -Wuninitialized reports it even at `default` \-O0. In the second example, timeout\_ms is assigned only inside the if block in read\_timeout\_ms(), so it is uninitialized on only one path. That case belongs to -Wmaybe-uninitialized, which relies on the data-flow analysis done by the optimizer, so it does not run at -O0.
If you build the same file at -O2, GCC does catch it:
~/cpp_26_uninitialised$ g++ -std=c++23 -O2 -Wall -Werror config_timeout_warning_test.cpp -o timeout_warning_test
config_timeout_warning_test.cpp: In function ‘int read_timeout_ms(std::string_view)’:
config_timeout_warning_test.cpp:24:12: error: ‘timeout_ms’ may be used uninitialized [-Werror=maybe-uninitialized]
24 | return timeout_ms;
| ^~~~~~~~~~
config_timeout_warning_test.cpp:11:9: note: ‘timeout_ms’ was declared here
11 | int timeout_ms;
| ^~~~~~~~~~
cc1plus: all warnings being treated as errors
This is still not a guarantee. The result of -Wmaybe-uninitialized depends on the optimization level and on how much the optimizer can see, so it can change between GCC versions and between builds. Debug builds are usually at -O0, which is exactly where the warning is missing.
If there is anything that I have missed, please comment; I'm happy to be corrected.
https://redd.it/1wyvcvg
@r_cpp
C++20 modules support: 228 projects already available to be consumed
Hello everyone.
I checked arewemodulesyet.org, which I do from time to time.
I was very positively surprised bc a couple of months ago there were 109 projects with modules support.
Now it is 228 and some of the most popular are there: fmt, ftxui, nlohmann.json and others.
So I had to share it with the community.
https://redd.it/1wfbh1d
@r_cpp
University of Waterloo user study on understanding CMake changes
Hi everyone,
I’m Mattie Nejati, a Ph.D. candidate at the University of Waterloo. I’m conducting a user study on understanding the impact of changes to CMake build specifications, and I’d love to invite members of this community to participate.
We are evaluating a new approach that aims to help developers identify how a change to a CMake build specification affects the resulting build configuration.
The study:
is conducted entirely online;
takes about one hour;
involves inspecting changes to CMake build specifications and identifying their impact; and
is open to adults aged 18–64 with any level of experience in CMake, programming, or code review.
You do not need to be a CMake expert. We are specifically interested in comparing participants with different levels of experience.
You will need a computer with internet access and about 4 GB of free space to download the files required for the tasks.
We will not collect your name. Your email address will only be used for study follow-up and will be stored separately from your study data. Your name or email will not appear in any dataset or publication.
The study has received clearance from the University of Waterloo Research Ethics Board (REB #46621).
If you’re interested, you can find the consent form, screening questionnaire, and study here:
https://buiscout.cs.uwaterloo.ca/
Thank you very much! And if you know someone else who works with CMake who might be interested, I’d really appreciate you sharing the study with them.
https://redd.it/1wyp45m
@r_cpp
Boost.Graph 1.95 will be C++17
Dear Boost.Graph community,
In two release cycles (Boost release 1.95 in summer 2027) Boost.Graph will be bumped to C++17 😄
This decision follows two polls that did not surface any C++14 user base or demand while identifiying users stuck in C++17:
[Bumping BGL's minimum C++ standard: input wanted on target version #490](https://github.com/boostorg/graph/discussions/490)
Reddit poll
This standard version bump will bring benefits for maintenance, API and dependencies reduction:
`if constexpr`,
constexpr lambdas,
`[[nodiscard]]`, `[[maybe_unused]]` ...
std::any instead of boost::any
`std::invoke_result` instead of `boost::result_of`
...
We will not be able to guarantee backward compatibility with C++14. Please contact us if you are stuck in C++14.
The GIthub Discussion lives here: https://github.com/boostorg/graph/discussions/613
https://redd.it/1wt531i
@r_cpp
myStringStream.str("") Considered Harmful Under C++20
I was recently looking at some (rather old) code that was relying on std::ostringstream in a large, performance senstive loop. (Yes, I know using iostreams in performance sensitive code is a bad idea, but legacy code exists.)
The code was using a common pattern to reset a ostringstream instance each time through the loop to avoid having to construct a new instance every time.
std::ostringstream oss;
for(const MyType & value : values)
{
oss << value;
doSomethingWithString(oss.str());
// Assign an empty string to the internal buffer. This should reset
// the size to zero, but keep the allocated buffer. In older code,
// you often see this written as oss.str("").
oss.str({});
oss.clear(); // Reset the stream
}
When migrating the code to C++20, I was excited to use the new std::ostringstream::view() getter to skip an unnecessary copy of the std::string out of the stream's internal buffer.
std::ostringstream oss;
for(const MyType & value : values)
{
oss << value;
doSomethingWithStringView(oss.view());
oss.str({});
oss.clear();
}
Then I noticed that the std::ostringstream::str setter gained an r-value reference overload in C++20. That would let us pre-allocate our string buffer just once. Nice!
std::ostringstream oss;
{
std::string buffer;
buffer.reserve(1024);
oss.str(std::move(buffer));
}
for(const MyType & value : values)
{
oss << value;
doSomethingWithStringView(oss.view());
oss.str({});
oss.clear();
}
But wait. That means that the oss.str({}) call inside the loop is doing the exact same thing. So it's wiping out our allocation every time through the loop! Uh oh.
It seems that to clear the internal buffer while keeping its allocation, one must now explicitly call the const reference overload of str().
const std::string empty;
std::ostringstream oss;
{
std::string buffer;
buffer.reserve(1024);
oss.str(std::move(buffer));
}
for(const MyType & value : values)
{
oss << value;
doSomethingWithStringView(oss.view());
oss.str(empty);
oss.clear();
}
So if your codebase uses std::ostringstream, you might want to do a quick grep for str("") and str({}) to see if the upgrade to C++20 silently caused you to start throwing away your stream buffers over and over again.
https://redd.it/1wp1ydk
@r_cpp
Inside Boost.PolyCollection
https://bannalia.blogspot.com/2026/09/inside-boostpolycollection.html
https://redd.it/1wgc6xo
@r_cpp
MSVC C++23: constexpr cmath with LLVM Libc
https://devblogs.microsoft.com/cppblog/msvc-c23-constexpr-cmath-with-llvm-libc/
https://redd.it/1wcx97o
@r_cpp
On forcing all derived classes to implement a specific non-virtual method, part 2
https://devblogs.microsoft.com/oldnewthing/20260828-00/?p=112654
https://redd.it/1w25y95
@r_cpp
New C++ Conference Videos Released This Month - August 2026 (Updated To Include Videos Released 2026-08-17 - 2026-08-23)
C++Now
2026-08-17 - 2026-08-23
Coroutines for Dummies - Dominic Fischer - [https://youtu.be/apLDto3FUVA](https://youtu.be/apLDto3FUVA)
Compile-Time Borrow Checker with Stateful Metaprogramming - Alon Wolf - https://youtu.be/3hL8mh0K8-I
Algorithms for Trees - Foldable, Applicative, Traversable - Steve Downey - [https://youtu.be/vfXKH7Uj170](https://youtu.be/vfXKH7Uj170)
2026-08-10 - 2026-08-16
After Reflection: The Runtime Story - Saksham Sharma - https://youtu.be/bUmt9K1o1d0
A Little Introduction to Control Flow Integrity in C++ - James McNellis - [https://youtu.be/FNHMwi\_0psQ](https://youtu.be/FNHMwi_0psQ)
Towards Async Everything Part 1 - Senders as the Lowest Layer - Robert Leahy - https://youtu.be/3PI31yqjI\_w
Towards Async Everything Part 2 - Scopes, Construction, and Destruction - Robert Leahy - Robert Leahy - [https://youtu.be/Hgdikbfu9UE](https://youtu.be/Hgdikbfu9UE)
2026-08-03 - 2026-08-09
How To Make Formal Methods A Software Quality Solution That Can Actually Be Used In The Industry - Steve Barriault - https://youtu.be/OYwDdMCCDIM
Link What You Include - Maintain a Coherent CMake Target Model - Frank Miller - [https://youtu.be/ssTG6uzxXm4](https://youtu.be/ssTG6uzxXm4)
Scaling beman.exemplar - Eddie Nolan - https://youtu.be/xylmqy1VAwo
2026-07-27 - 2026-08-02
Beautiful C++ Code - Told Through the Eyes of A Failed AI Prompt - Erich Lohrmann - [https://youtu.be/Kq4W3Y5gTI8](https://youtu.be/Kq4W3Y5gTI8)
A Path to Practically Safe C++ - Yitzhak Mandelbaum - https://youtu.be/fi6csDXvve0
When Abstractions Fix Too Much - Towards Flexible Library Design - Patrick Roberts - [https://youtu.be/IKIyFUcVvis](https://youtu.be/IKIyFUcVvis)
C++Online
2026-08-17 - 2026-08-23
Lightning Talk: Bazelizing a C++ Project - Paulo Chiliguano - https://youtu.be/agAbiQydcOQ
Lightning Talk: Can We Still Find Joy in Programming? - Sandor Dargo - [https://youtu.be/WxqeLwyw0KM](https://youtu.be/WxqeLwyw0KM)
2026-08-10 - 2026-08-16
Lightning Talk: Saving Time With Runtime and Having Registry Level Synthesis of Your Software As You Write It - Michael Hubbard - https://youtu.be/B0JJwWMUzzw
Lightning Talk: 2 New Nice CMake Features I Learned in 2025 - Lieven de Cock - [https://youtu.be/YnWJyHxHpBc](https://youtu.be/YnWJyHxHpBc)
2026-08-03 - 2026-08-09
Lightning Talk: Your Docs Have a New Reader (and It Hallucinates) - Paul Wicking - https://youtu.be/DbL6XPMlw-o
Lightning Talk: RPC With Coroutines, RAII and Callable Weakpointers - Edward Boggis-Rolfe - [https://youtu.be/m70hb5YgabQ](https://youtu.be/m70hb5YgabQ)
2026-07-27 - 2026-08-02
Dynamic Asynchronous Tasking with Dependencies - Tsung-Wei (TW) Huang - https://youtu.be/4LzQHw7jz2g
C++/sys - A Standard Library Projection to Facilitate the Verification of Run-time Memory Safety - Karsten Pedersen - [https://youtu.be/dF7RwJw\_G8c](https://youtu.be/dF7RwJw_G8c)
ADC
2026-08-17 - 2026-08-23
How To Distribute Your Plugins - Using MuseHub as the Engine To Get Your Audio Tools in the Hands of Millions - Khaled Said - https://youtu.be/CQTblE1xHto
Incline - Topographic Microsound Explorer - Cristián Vogel - [https://youtu.be/lJA00sRFhGg](https://youtu.be/lJA00sRFhGg)
Optimizing UI Rendering Performance in Cubase and Nuendo - Erich Krey - https://youtu.be/Oz1dZLcXVjs
2026-08-10 - 2026-08-16
Measuring and Improving UI Performance with the JUCE C++ Framework - Anthony Nicholls - [https://youtu.be/0n9x6R0fheo](https://youtu.be/0n9x6R0fheo)
Real-Time Raytraced Acoustics for Games: Dynamic Reverb with IR Synthesis &
Reducing C++ template bloat by factoring out the type-dependent portions of the function
https://devblogs.microsoft.com/oldnewthing/20260820-00/?p=112629
https://redd.it/1vv0ohd
@r_cpp
P4444: std::big_int
https://isocpp.org/files/papers/D4444R0.html
https://redd.it/1vrk2cj
@r_cpp
New C++ Conference Videos Released This Month - August 2026 (Updated To Include Videos Released 2026-08-10 - 2026-08-16)
**C++Now**
2026-08-10 - 2026-08-16
* After Reflection: The Runtime Story - Saksham Sharma - [https://youtu.be/bUmt9K1o1d0](https://youtu.be/bUmt9K1o1d0)
* A Little Introduction to Control Flow Integrity in C++ - James McNellis - [https://youtu.be/FNHMwi\_0psQ](https://youtu.be/FNHMwi_0psQ)
* Towards Async Everything Part 1 - Senders as the Lowest Layer - Robert Leahy - [https://youtu.be/3PI31yqjI\_w](https://youtu.be/3PI31yqjI_w)
* Towards Async Everything Part 2 - Scopes, Construction, and Destruction - Robert Leahy - Robert Leahy - [https://youtu.be/Hgdikbfu9UE](https://youtu.be/Hgdikbfu9UE)
2026-08-03 - 2026-08-09
* How To Make Formal Methods A Software Quality Solution That Can Actually Be Used In The Industry - Steve Barriault - [https://youtu.be/OYwDdMCCDIM](https://youtu.be/OYwDdMCCDIM)
* Link What You Include - Maintain a Coherent CMake Target Model - Frank Miller - [https://youtu.be/ssTG6uzxXm4](https://youtu.be/ssTG6uzxXm4)
* Scaling beman.exemplar - Eddie Nolan - [https://youtu.be/xylmqy1VAwo](https://youtu.be/xylmqy1VAwo)
2026-07-27 - 2026-08-02
* Beautiful C++ Code - Told Through the Eyes of A Failed AI Prompt - Erich Lohrmann - [https://youtu.be/Kq4W3Y5gTI8](https://youtu.be/Kq4W3Y5gTI8)
* A Path to Practically Safe C++ - Yitzhak Mandelbaum - [https://youtu.be/fi6csDXvve0](https://youtu.be/fi6csDXvve0)
* When Abstractions Fix Too Much - Towards Flexible Library Design - Patrick Roberts - [https://youtu.be/IKIyFUcVvis](https://youtu.be/IKIyFUcVvis)
**C++Online**
2026-08-10 - 2026-08-16
* Lightning Talk: Saving Time With Runtime and Having Registry Level Synthesis of Your Software As You Write It - Michael Hubbard - [https://youtu.be/B0JJwWMUzzw](https://youtu.be/B0JJwWMUzzw)
* Lightning Talk: 2 New Nice CMake Features I Learned in 2025 - Lieven de Cock - [https://youtu.be/YnWJyHxHpBc](https://youtu.be/YnWJyHxHpBc)
2026-08-03 - 2026-08-09
* Lightning Talk: Your Docs Have a New Reader (and It Hallucinates) - Paul Wicking - [https://youtu.be/DbL6XPMlw-o](https://youtu.be/DbL6XPMlw-o)
* Lightning Talk: RPC With Coroutines, RAII and Callable Weakpointers - Edward Boggis-Rolfe - [https://youtu.be/m70hb5YgabQ](https://youtu.be/m70hb5YgabQ)
2026-07-27 - 2026-08-02
* Dynamic Asynchronous Tasking with Dependencies - Tsung-Wei (TW) Huang - [https://youtu.be/4LzQHw7jz2g](https://youtu.be/4LzQHw7jz2g)
* C++/sys - A Standard Library Projection to Facilitate the Verification of Run-time Memory Safety - Karsten Pedersen - [https://youtu.be/dF7RwJw\_G8c](https://youtu.be/dF7RwJw_G8c)
**ADC**
2026-08-10 - 2026-08-16
* Measuring and Improving UI Performance with the JUCE C++ Framework - Anthony Nicholls - [https://youtu.be/0n9x6R0fheo](https://youtu.be/0n9x6R0fheo)
* Real-Time Raytraced Acoustics for Games: Dynamic Reverb with IR Synthesis & Time-Varying Convolution - Anton Lundberg - [https://youtu.be/iT0olrM1iyU](https://youtu.be/iT0olrM1iyU)
* Building an Optimized DSP Framework in Modern C++ - Scott Carver - [https://youtu.be/k4yxNxNCo0k](https://youtu.be/k4yxNxNCo0k)
2026-08-03 - 2026-08-09
* Commercialising Audio Plugins - Going From Development to Sales and Beyond - Tobias Lønnerød Madsen - [https://youtu.be/SWPLyDDBU38](https://youtu.be/SWPLyDDBU38)
* Capturing and Transferring Expressive Microtiming in Drumming - Eemi Fagerlund - [https://youtu.be/4ZAJHl02X7s](https://youtu.be/4ZAJHl02X7s)
* How I Learned to Love the Docs - Documentation As Design Process for Music Tech Products - Astrid Bin - [https://youtu.be/7MpDAHd7rbw](https://youtu.be/7MpDAHd7rbw)
2026-07-27 - 2026-08-02
* Workshop: Programming Music and Synthesizers on-the-fly with Pharo - Domenico Cipriani - [https://youtu.be/v95QYyUHNJ8](https://youtu.be/v95QYyUHNJ8)
* PolyBLEP & PolyBLAMP Demystified - Nis Wegmann - [https://youtu.be/\_bW8TfgEqRM](https://youtu.be/_bW8TfgEqRM)
* Modernizing Legacy Audio Plugin Codebases - Lessons from FL Studio’s Plugin Suite - Tomas Medek -
WasmBolt — The LLVM Project in your browser
https://anutosh21.github.io/WasmBolt/
https://redd.it/1wcbjng
@r_cpp
Why do people on Windows mostly choose Visual Studio?
https://redd.it/1weku08
@r_cpp
It annoys me that coroutines are described as "functions that can be suspended"
Any function can be suspended. It literally happens constantly when a process or thread gets pre-empted by the OS or asynchronous hardware, with the stack being the mechanism to save to and restore context from. So, this super common way of describing coroutines is just frustrating because it's not it!
Coroutines are functions that can be suspended in a **controlled, intentional (as in, explicitly expressed) way**, with the relevant context (coroutine frame) being placed _not_ on the stack like a function's usual context, but on the heap (usually).
I wish someone had broken it down for me in this way before, so hopefully it helps someone else too.
https://redd.it/1wgm4jx
@r_cpp
No, -Wall -Werror Does Not Guarantee Detection of Conditionally Uninitialized Local Variables
There seems to be a misconception or lack of clarity about the usage of the compilation flags -Wall and -Werror and their ability to detect uninitialized stack variables. It depends. In this post, I will try to explore this further and explain when and how it is detected, and where it may not detect an uninitialized local variable and hence requires more caution while dealing with it. Consider the following code:
int main()
{
int value;
return value;
}
Compile this code as follows:
~/cpp_26_uninitialised$ g++ -std=c++23 -Wall -Werror test.cpp -o test
test.cpp: In function ‘int main()’:
test.cpp:4:12: error: ‘value’ is used uninitialized [-Werror=uninitialized]
4 | return value;
| ^~~~~
test.cpp:3:9: note: ‘value’ was declared here
3 | int value;
| ^~~~~
cc1plus: all warnings being treated as errors
So, with the use of the two compilation flags, `-Wall` and `-Werror`, the compilation fails, and you can then take corrective measures to address the uninitialized variable in the code.
Strictly speaking, -Wall enables the -Wuninitialized warning, and -Werror turns that warning into an error. However, *this is true only when the variable is uninitialized on every path to its use*, as `value` is here. It doesn't reliably work for a variable that is initialized on some paths and left uninitialized on others. Have a look at the following code:
// config_timeout_warning_test.cpp
#include <charconv>
#include <cstdio>
#include <string_view>
constexpr int default_timeout_ms = 1000;
// Reads "timeout_ms=<number>" from a device configuration line.
// The bug: when the key is missing, timeout_ms is never assigned.
[[gnu::noinline]] int read_timeout_ms(std::string_view config)
{
int timeout_ms;
constexpr std::string_view key = "timeout_ms=";
if (const auto pos = config.find(key); pos != std::string_view::npos)
{
const char* first = config.data() + pos + key.size();
const char* last = config.data() + config.size();
std::from_chars(first, last, timeout_ms);
}
return timeout_ms;
}
void open_device(const char* name, std::string_view config)
{
const int timeout_ms = read_timeout_ms(config);
if (timeout_ms <= 0)
{
std::printf("%-7s no timeout configured, using default %d ms\n", name, default_timeout_ms);
}
else
{
std::printf("%-7s timeout %d ms\n", name, timeout_ms);
}
}
int main()
{
// The empty configuration does not contain "timeout_ms=".
// Therefore, timeout_ms is returned without being initialized.
open_device("logger", "");
return 0;
}
Compile the code as follows:
~/cpp_26_uninitialised$ g++ -std=c++23 -O0 -g -Wall -Werror config_timeout_warning_test.cpp -o timeout_warning_test
The compilation succeeds without a single warning. Run Valgrind on it:
~/cpp_26_uninitialised$ valgrind --track-origins=yes ./timeout_warning_test
==2896379== Memcheck, a memory error detector
==2896379== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2896379== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==2896379== Command: ./timeout_warning_test
==2896379==
==2896379== Conditional jump or move depends on uninitialised value(s)
==2896379== at 0x401268: open_device(char const*, std::basic_string_view<char, std::char_traits<char> >) (config_timeout_warning_test.cpp:31)
==2896379== by 0x4012D3: main (config_timeout_warning_test.cpp:45)
==2896379== Uninitialised value was created by a stack allocation
==2896379== at 0x401166: read_timeout_ms(std::basic_string_view<char, std::char_traits<char> >) (config_timeout_warning_test.cpp:10)
operator<>: A Dream of Higher-order Metaprogramming Parity
https://www.elbeno.com/blog/?p=1871
https://redd.it/1wfuo4i
@r_cpp
Try to Implement Reflection Annotations in C++20
https://typecombinator.github.io/en/posts/implementing\_annotations\_for\_reflection\_in\_cpp20
https://redd.it/1wg4pxf
@r_cpp
Token Sequence Injection & Modern Macros: The Most Game-Changing Compile-Time Feature in C++29 (Try it on Compiler Explorer with Barry's Clang Compiler!)
https://open-std.org/JTC1/SC22/WG21/docs/papers/2026/p4380r0.html
https://redd.it/1wq2jld
@r_cpp
A clever branch free optimization
I'm the developer of memlz which is an extremely fast compression library.
We have `char* src, char* dst` for the source and destination buffers and `uint16_t flags` that we prepend bits to one at a time. The inner core looks something like this (pseudo code):
flags <<= 1;
uint64_t payload = ((uint64_t*)src)[i];
uint16_t hash_index = hash_function(payload);
if (hash_table[hash_index] == payload) {
flags |= 1;
*(uint16_t*)dst = (uint16_t)hash_index;
dst += sizeof(uint16_t);
}
else {
*(uint64_t*)dst = payload;
hash_table[hash_index] = payload;
dst += sizeof(uint64_t);
}
Depending on a hash comparison we need to output either 2 or 8 bytes, advance `dst` accordingly and prepend either a 1 or a 0 to `flags`.
Furthermore, at the end it's required that `hash_table[hash_index] == payload`, so we update `hash_table` in the false-case.
Let's benchmark it with 211 MB input so it's uncached:
memlz: 2744 MB/s
Now let's look at an amazing idea. The output to `*dst` can be rewritten with the ternary operator:
`*(uint64_t*)dst = hit ? hash_index : payload;`
That turns into a compare instruction (`cmp`) and a conditional move instruction (`cmove`) with no branching:
00007FF742A5A55B mov rax,r10
00007FF742A5A55E cmp rcx,r10
...
00007FF742A5A56D cmove rax,rdx
00007FF742A5A571 mov qword ptr [rdi],rax
The advancement of `dst` is also simple to make branchless, noting that `hit` will turn either 0 or 1:
uint64_t hit = (hash_table[hash_index] == payload);
dst += 8 - (hit * 6);
Now look at updating the `hash_table` where we update it to `payload` only if it differed from `payload`. What we can do is update it unconditionally at the end, and hope that the extra number of unnecessary writes to memory (where it just overwrites the same value) are not too expensive.
Final branch-free version:
uint64_t payload = ((uint64_t*)src)[i];
uint16_t hash_index = hash_function(payload);
flags <<= 1;
uint64_t hit = (hash_table[hash_index] == payload);
flags |= hit;
*(uint64_t*)dst = hit ? hash_index : payload;
hash_table[hash_index] = payload;
dst += 8 - (hit * 6);
Let's benchmark it:
memlz: 4269 MB/s
I had never believed such gains were possible because I had been micro-optimizing on this for weeks.
I later achieved 5070 MB/s. To put it in perspective, uncached memcpy runs at 14000 MB/s here and LZ4 - another popular fast compression library - at 718 MB/s.
https://redd.it/1wkuou2
@r_cpp
C++26: Standard Library Hardening Experiments
https://www.cppstories.com/2026/hardening-experiments/
https://redd.it/1wdd4da
@r_cpp
C++ Show and Tell - September 2026
Use this thread to share anything you've written in C++. This includes:
* a tool you've written
* a game you've been working on
* your first non-trivial C++ program
The rules of this thread are very straight forward:
* The project must involve C++ in some way.
* It must be something you (alone or with others) have done.
* Please share a link, if applicable.
* Please post images, if applicable.
If you're working on a C++ library, you can also share new releases or major updates in a dedicated post as before. The line we're drawing is between "written in C++" and "useful for C++ programmers specifically". If you're writing a C++ library or tool for C++ developers, that's something C++ programmers can use and is on-topic for a main submission. It's different if you're just using C++ to implement a generic program that isn't specifically about C++: you're free to share it here, but it wouldn't quite fit as a standalone post.
Last month's thread: https://www.reddit.com/r/cpp/comments/1vhdqw8/c_show_and_tell_august_2026/
https://redd.it/1w776o7
@r_cpp
Time-Varying Convolution - Anton Lundberg - https://youtu.be/iT0olrM1iyU
Building an Optimized DSP Framework in Modern C++ - Scott Carver - [https://youtu.be/k4yxNxNCo0k](https://youtu.be/k4yxNxNCo0k)
2026-08-03 - 2026-08-09
Commercialising Audio Plugins - Going From Development to Sales and Beyond - Tobias Lønnerød Madsen - https://youtu.be/SWPLyDDBU38
Capturing and Transferring Expressive Microtiming in Drumming - Eemi Fagerlund - [https://youtu.be/4ZAJHl02X7s](https://youtu.be/4ZAJHl02X7s)
How I Learned to Love the Docs - Documentation As Design Process for Music Tech Products - Astrid Bin - https://youtu.be/7MpDAHd7rbw
2026-07-27 - 2026-08-02
Workshop: Programming Music and Synthesizers on-the-fly with Pharo - Domenico Cipriani - [https://youtu.be/v95QYyUHNJ8](https://youtu.be/v95QYyUHNJ8)
PolyBLEP & PolyBLAMP Demystified - Nis Wegmann - https://youtu.be/\_bW8TfgEqRM
Modernizing Legacy Audio Plugin Codebases - Lessons from FL Studio’s Plugin Suite - Tomas Medek - [https://youtu.be/zY8uHzAdnzk](https://youtu.be/zY8uHzAdnzk)
How to Write Scalable, Deterministic Audio Engines - Janus Lynggaard Thorborg - https://youtu.be/3FXQQmQa-ak
https://redd.it/1vx94b9
@r_cpp
C++26 Contracts: What Do They Add Beyond Manual Checks and Assertions?
https://techfortalk.co.uk/2026/08/22/cpp26-contracts/
https://redd.it/1vv9uad
@r_cpp
Is there a way to track reflection support status in Clang?
(I'm going to be bold and assume the "no questions" rule is for questions about specific code, not about discussing the language itself)
I am extremely happy that we have reflection in C++26, however currently it is GCC only. I am using Clang on all platforms, so I am curious about when it will get reflection.
I tried searching and I found a bunch of experimental forks with reflection. I am not sure if those track the current version of reflection and whether one of these is going to be merged, or if a new implementation will be created. Github issues basically say "we get it when we get it" and link to LLVM discourse. On discourse I found just a thread that a meeting on reflection was held in December.
Do you know either when we are getting reflection, or if there is some way to track its progress for outside observers? Thanks!
https://redd.it/1vsmdo9
@r_cpp
[https://youtu.be/zY8uHzAdnzk](https://youtu.be/zY8uHzAdnzk)
* How to Write Scalable, Deterministic Audio Engines - Janus Lynggaard Thorborg - [https://youtu.be/3FXQQmQa-ak](https://youtu.be/3FXQQmQa-ak)
https://redd.it/1vqvhzt
@r_cpp
C++ Show and Tell - August 2026
Use this thread to share anything you've written in C++. This includes:
* a tool you've written
* a game you've been working on
* your first non-trivial C++ program
The rules of this thread are very straight forward:
* The project must involve C++ in some way.
* It must be something you (alone or with others) have done.
* Please share a link, if applicable.
* Please post images, if applicable.
If you're working on a C++ library, you can also share new releases or major updates in a dedicated post as before. The line we're drawing is between "written in C++" and "useful for C++ programmers specifically". If you're writing a C++ library or tool for C++ developers, that's something C++ programmers can use and is on-topic for a main submission. It's different if you're just using C++ to implement a generic program that isn't specifically about C++: you're free to share it here, but it wouldn't quite fit as a standalone post.
Last month's thread: https://www.reddit.com/r/cpp/comments/1umnaxs/c_show_and_tell_july_2026/
https://redd.it/1vhdqw8
@r_cpp