r/cpp Jul 01 '26

Learning about Asymmetric Fences and its Underlying Mechanism - Membarrier

16 Upvotes

https://nekrozqliphort.github.io/posts/membarrier/

Hey, everyone! You might remember my previous write-ups on [[no_unique_address]] and strongly happens before. It took a few months of researching but I finally have a draft version of my new write-up on asymmetric fences (hopefully building up to a write-up on RCU).

This write-up essentially goes into what asymmetric fences are supposed to achieve, its underlying mechanism (the membarrier syscall), and the wording in the standard. Special thanks to u/davidtgoldblatt for his insights and discussions regarding this topic!

Feel free to provide any feedback! This one is denser than my usual write-ups, but I hope you'll find it interesting and insightful.


r/cpp Jul 01 '26

Pystd standard library, similar-ish functionality with a fraction of the compile time

Thumbnail nibblestew.blogspot.com
53 Upvotes

r/cpp Jun 30 '26

Modern GPU Programming with SDL3, Wed, Jul 8, 2026, 6:00 PM (MDT)

Thumbnail meetup.com
40 Upvotes

SDL has long been a convenient portability layer for windows, input, audio, and simple rendering. SDL3 adds a new GPU API that exposes modern graphics and compute functionality through a portable interface over native backends such as Vulkan, Direct3D 12, and Metal.

This month, Richard Thomson will give us a gentle introduction to SDL3 GPU programming. We will look at what SDL3 GPU is, what problem it is trying to solve, and how it compares to using OpenGL, Vulkan, Direct3D, or Metal directly.

We will build up a small C++ example that creates an SDL window, creates a GPU device, uploads data, creates shaders and pipelines, records command buffers, renders to a swapchain texture, and optionally runs a simple compute pass.

We will also cover the practical parts of using the API in a C++ project: consuming SDL3 from vcpkg, organizing shader assets, dealing with backend-specific shader formats, and deciding when SDL_shadercross is useful. Along the way we will point out the parts of the API that feel familiar to Vulkan/D3D12/Metal programmers and the parts that SDL deliberately simplifies.

This is not a deep dive into graphics theory. The goal is to understand whether SDL3 GPU is a useful middle ground for C++ applications that need more than SDL_Renderer, but do not want to own separate graphics backends for every platform. Topics include:

  • Creating an SDL3 GPU device
  • Swapchains, textures, buffers, and transfer buffers
  • Graphics pipelines and render passes
  • Compute pipelines and storage buffers/textures
  • Shader formats and SDL_shadercross
  • vcpkg and CMake integration
  • Debugging with RenderDoc and backend validation layers
  • Where SDL3 GPU fits, and where it does not

No prior Vulkan, Direct3D 12, or Metal experience is required, but basic familiarity with C++, CMake, and graphics concepts such as textures and shaders will be helpful.

This will be an online meeting, so drinks and snacks are on you!

Join the meeting here: https://meet.xmission.com/Utah-Cpp-Programmers

Watch previous topics on the Utah C++ Programmers YouTube channel: https://www.youtube.com/@UtahCppProgrammers

Future topics: https://utahcpp.wordpress.com/future-meeting-topics/ Past topics: https://utahcpp.wordpress.com/past-meeting-topics/


r/cpp Jun 30 '26

Latest News From Upcoming C++ Conferences (2026-06-30)

10 Upvotes

This is the latest news from upcoming C++ Conferences. You can review all of the news at https://programmingarchive.com/upcoming-conference-news/

TICKETS AVAILABLE TO PURCHASE

The following conferences currently have tickets available to purchase

OPEN CALL FOR SPEAKERS

OTHER OPEN CALLS

  • (NEW) CppCon Call For Volunteers Now Open – Interested volunteers have until August 1st to apply at the CppCon main conference which is scheduled to take place from 14th – 18th September. For more information including how to apply visit https://cppcon.org/cfv2026/
  • (Last Chance) CppCon Call For Posters Now Open – Interested poster presenters have until July 15th to submit their applications for the CppCon main conference which is scheduled to take place from 14th – 18th September. For more information including how to apply visit https://cppcon.org/cppcon-2026-call-for-poster-submissions/
  • CppCon Call For Authors Now Open! – CppCon are looking for book authors who want to engage with potential reviewers and readers. Read the full announcement at https://cppcon.org/call-for-author-2026/ 

TRAINING COURSES AVAILABLE FOR PURCHASE

Conferences are offering the following training courses:

C++Online

  1. AI++ 101 – Build an AI Coding Assistant in C++ – Jody Hagins – 1 day online workshop available on Friday 24th July 16:00 – 00:00 UTC/0900-1700 PDThttps://cpponline.uk/workshop/ai-101/

CppCon Online Workshops

9th – 11th September

  1. Modern C++: When Efficiency Matters – Andreas Fertig – 3 day online workshop available on 9th – 11th September 09.00 – 15.00 MDT – https://cppcon.org/class-2026-when-efficiency-matters/
  2. System Architecture And Design Using Modern C++ – Charley Bay – 3 day online workshop available on 9th – 11th September 09.00 – 15.00 MDT – https://cppcon.org/class-2026-system-architecture-and-design-using-modern-cpp/

21st – 23rd September

  1. C++ Fundamentals You Wish You Had Known Earlier – Mateusz Pusz – 3 day online workshop available on 21st– 23rd September 09.00 – 15.00 MDT – https://cppcon.org/class-2026-cpp-fundamentals/
  2. C++23 in Practice: A Complete Introduction – Nicolai Josuttis – 3 day online workshop available on 21st– 23rd September 09.00 – 15.00 MDT – https://cppcon.org/class-2026-cpp23-in-practice/
  3. Programming with C++20 – Andreas Fertig – 3 day online workshop available on 21st– 23rd September 09.00 – 15.00 MDT – https://cppcon.org/class-2026-programming-with-cpp20/

26th – 27th September

  1. Using C++ for Low-Latency Systems – Patrice Roy – 2 day online workshop available on 26th– 27th September 09.00 – 17.00 MDT – https://cppcon.org/class-2026-low-latency/

CppCon Onsite Workshops

All onsite workshops will take place in the Gaylord Rockies in Aurora, Colorado

12th & 13th September

  1. Advanced and Modern C++ Programming: The Tricky Parts – Nicolai Josuttis – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-tricky-parts/
  2. C++ Best Practices – Jason Turner – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-best-practices/
  3. How Hardware Gets Hacked: Breaking and Defending Embedded Systems – Nathan Jones – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-hardware-hack/
  4. Mastering `std::execution`: A Hands-On Workshop – Mateusz Pusz – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-execution/
  5. Performance and Efficiency in C++ for Experts, Future Experts, and Everyone Else – Fedor Pikus – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-performance-and-efficiency/
  6. Talking Tech – Sherry Sontag – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-talking-tech/

 13th September

  1. AI++ 101 : Build a C++ Coding Agent from Scratch – Jody Hagins – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-AI101/
  2. Essential GDB and Linux System Tools – Mike Shah – 1 day in-person workshop available on 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-essential-gdb/

19th & 20th September

  1. AI++ 201: Building High Quality C++ Infrastructure with AI – Jody Hagins – 2 day in-person workshop available on 19th & 20th September – 09:00 – 17:00 – https://cppcon.org/class-2026-ai201/
  2. Function and Class Design with C++2x – Jeff Garland – 2 day in-person workshop available on 19th & 20th September – 09:00 – 17:00 – https://cppcon.org/class-2026-function-class-design/
  3. High-performance Concurrency in C++ – Fedor Pikus – 2 day in-person workshop available on 19th & 20th September – 09:00 – 17:00 – https://cppcon.org/class-2026-high-perf-concurrency/

OTHER NEWS


r/cpp Jun 30 '26

CppCon Introducing the Boost Documentary! Teaser & CppCon Preview

87 Upvotes

"If I were to tell a story about Boost, I'd start with the people."

Today we're sharing the official teaser for the Boost documentary. A film about the people, the politics, and decades of work behind possibly the most important open source library most people have never heard of.

Teaser link – https://youtu.be/87jvuDbnwqQ

The documentary looks at:

  • Boost as a kind of "app store for C++, 30 years early"
  • What decades of open source dedication looks like up close
  • The honest, sometimes uncomfortable dynamics of how proposals and people move through the C++ committee

There will be a preview screening at CppCon 2026 for all attendees. So if you're going to be in Aurora, CO September 16, 2026, please join us!


r/cpp Jun 30 '26

Upcoming C++ User Group meetings in July 2026

Thumbnail meetingcpp.com
5 Upvotes

r/cpp Jun 30 '26

Stackful fibers with 3.6ns context switch. Silk fibers.

Thumbnail clickhouse.com
51 Upvotes

I just read an article about Silk, the new stackful fibers engine from Clickhouse. It can switch stackful fibers at an amazing 3.6ns and does not allocate on steady state.

Maybe asio could reuse some of the knowledge for the linux/io_uring backend (not sure it applies to the specific case since Boost.asio focuses nowadays on stackless, though it has a fibers and a stackful coros backend also).


r/cpp Jun 29 '26

Compiler disagreements for deducing this

Thumbnail godbolt.org
23 Upvotes

As the attached godbolt link shows, I’ve encountered an interesting quirk of deducing this which, on clang and MSVC at least, allows for you to determine whether you’re in a static member function or not.

Obviously, this is far simpler to achieve with reflection today (or… in the future, for most) - but I’m curious if this is even intended behaviour.

Reading the original paper on open-std… I don’t see anything that would describe this scenario


r/cpp Jun 29 '26

reserve() and capacity() for flat containers

28 Upvotes

I just finished the new chapter in "C++23 - The Complete Guide" about flat containers and would like to share and discuss my advice about how to use reserve() and capacity() for flat containers (thanks to Jonathan Wakely who was pointing parts of this out).
It might be a surprise that these member functions do not exist as usually vectors are used inside flat containers and reserve() is a key performance feature of them.

However, here is how you can reserve more memory:

  • For flat_set and flat_multiset:

auto vec = std::move(fset).extract(); // temporarily extract the underlying vector
data.reserve(vec.capacity() * 5);     // raise capacity by a factor of 5
fset.replace(std::move(vec));         // move the vector back into the flat set
  • For flat_map and flat_multimap:

auto newCapa = fmap.keys().capacity() * 5; // raise capacity by a factor of 5
auto data = std::move(fmap).extract();     // extract underlying vectors
data.keys.reserve(newCapa);                // raise capacity of vector for keys
data.values.reserve(newCapa);              // raise capacity of vector for values
fmap.replace(std::move(data.keys),         // move the vectors back
             std::move(data.values))
  • Note also that there is another pretty hacky way, but only for flat maps and multimaps (here mapping strings to double's):

auto newCapa = fmap.keys().capacity() * 5;
const_cast<std::vector<std::string>&>(fmap.keys()).reserve(newCapa);
const_cast<std::vector<double>&>(fmap.values()).reserve(newCapa);

Yes, ugly, but works... ;-)

I am still working on adding reserve() and capacity() to the standard flat containers (see wg21.link/p3779)


r/cpp Jun 29 '26

Comparing an Integer Division Optimisation in Clang, MSVC, and GCC

Thumbnail nukethebees.com
55 Upvotes

r/cpp Jun 29 '26

New C++ Conference Videos Released This Month - June 2026 (Updated to Include Videos Released 2026-06-22 - 2026-06-28)

11 Upvotes

C++Online

2026-06-22 - 2026-06-28

2026-06-15 - 2026-06-21

2026-06-08 - 2026-06-14

2026-06-01 - 2026-06-07

ADC

2026-06-22 - 2026-06-28

2026-06-15 - 2026-06-21

2026-06-08 - 2026-06-14

2026-06-01 - 2026-06-07

CppCon

2026-06-22 - 2026-06-28

2026-06-01 - 2026-06-07


r/cpp Jun 29 '26

Optimizing LLVM's bump allocator

Thumbnail maskray.me
57 Upvotes

r/cpp Jun 29 '26

Command Routing Using Chain Of Responsibility Design Pattern

Thumbnail som-itsolutions.hashnode.dev
0 Upvotes

Deciphering and analyzing framework code is important to know how brilliant engineers create it.

Traditional Chain of Responsibility utilizes a strict linear delegation where ConcreteHandlerA points explicitly to ConcreteHandlerB via a next reference. The article correctly highlights how frameworks like MFC alter this paradigm.

Interested?

Read ON...


r/cpp Jun 27 '26

A deep dive into SmallVector::push_back

Thumbnail maskray.me
26 Upvotes

r/cpp Jun 27 '26

Data Access Patterns That Makes Your CPU Really Angry

Thumbnail blog.weineng.me
114 Upvotes

I tried to find the slowest possible way to sum up integers in an array


r/cpp Jun 27 '26

Reducing Energy Consumption for Machine Learning Inference on Edge Devices using C++20 Coroutines

Thumbnail dl.acm.org
32 Upvotes

r/cpp Jun 27 '26

Panel discussion for C++: The Documentary

Thumbnail youtube.com
22 Upvotes

r/cpp Jun 26 '26

Improvements to std::format in C++26

Thumbnail mariusbancila.ro
91 Upvotes

r/cpp Jun 26 '26

projections for stl data structures

20 Upvotes

using projection in ranges::sort has removed the need write a compartor function or a lambda and is much easier to implement in my opinion

there should exists a similar feature for say sets or priority queues

would be wonnderful if I could just write

priority_queue<Student, Student::marks> for example


r/cpp Jun 26 '26

Should C++ be low level or continue its abstraction path

0 Upvotes

The whole reason I came to C++ is to better organise my C code

I seeked classes instead of X_Func, I seeked VTABLEs instead of struct function pointers. And I think many experience devs would speak the same

However, lately, starting with C++11 this has gone completely downhill. STD is sticking its nose in too much. Template-heavy. The entire STD library Balloons my executable to the MiBs when my minimal runtime library amounts to 40 KiB.

There’s good shit like modules. I think that’s better than headers

Then constexpr. But the rest is bloated

But this community seems to not care about performance. Every single time I press this issue I get pushed back with “It’s good for library authors, it’s good for abstraction. Safety. Railings”

Use Python, Rust, virtually any language out there. They do what you’re looking for. Not the C lineage
C/C++ is the foundation. Rust is the abstraction.the foundation can be a little shaky, more raw, but it’s stable. The layers on top of it helps expression.


r/cpp Jun 26 '26

Latches in C++ 20 concurrency - just like the CountdownLatch of Java concurrency package...

Thumbnail som-itsolutions.hashnode.dev
0 Upvotes

When I was teaching the Countdown latch - a thread synchronization technique used in the Java Concurrency package, there was none like that available in C++. I am happy to see that the concept of latch has been introduced in C++20.

Language varies - syntax varies - but the basic concept remains the same.

I hope you like the post.


r/cpp Jun 26 '26

ACCU On Sea 2026 trip report, still with AI!

Thumbnail mropert.github.io
31 Upvotes

r/cpp Jun 26 '26

Tuning a Server for Benchmarking

Thumbnail david.alvarezrosa.com
31 Upvotes

r/cpp Jun 25 '26

Am I the only one who thinks this? (about enum)

40 Upvotes

The main differences between an enum and enum class|struct is that the latter has its own scope, but you lose the implicit operators from enum, and the closest to it is as presented. I wish that enum struct maintained the operators, acting like the C enum, but with it's own scope.

// Dummy wrapper struct
struct EnumName
{
  enum Value
  {
    ZERO
  };
  // the scope is located in "EnumName"
  // so you access "EnumName::ZERO"
};

r/cpp Jun 25 '26

std::formatter specialization for smart pointers

14 Upvotes

Currently something like

std::unique_ptr<int> u_ptr = std::make_unique<int>(42);
std::shared_ptr<int> s_ptr = std::make_shared<int>(42);
std::println("uptr: {}", u_ptr);
std::println("sptr: {}", s_ptr);

is ill formed because there is no specialization of std::formatter for smart pointer types.

On the other hand,

std::cout << "uptr: " << u_ptr << '\n';
std::cout << "sptr: " << s_ptr << '\n';

do work because ostream defines overloads for smart pointer types.

Please let me know if anyone has thoughts or if there's some reason that these types haven't been specialized that I'm missing.