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
always works from an implementation point of view, even if I get ride of "#1" and mark "#2" as deleted (even with `-fsanitize=undefined`). Moreover, it doesn't restrict the development of the private implementation more than a pimpl and get ride of a pointer indirection. Last but not least, it can even be improved a bit if there is a guarantee that the size of `soo` will never change by inverting the storage, storing \`soo\` in `Coo` (and thus losing 1 byte of overhead) (but that's not the point here).
**Why is this a problem?**
For everyday C++ work it usually isn’t—most developers will just `reinterpret_cast` and move on, and in practice that’s fine. In safety-critical, out-of-context code, however, we have to treat the C++ Standard as a hard contract with any certified compiler. Anything that leans on *undefined behaviour*, no matter how convenient, is off-limits. (Maybe I’m over-thinking strict Standard conformance—even for a safety-critical scenario).
So the real question is: what is the best way to implement a zero-overhead C++ wrapper around a ref-counted C handle in a reliable manner?
Thanks in advance for any insights, corrections, or war stories you can share. Have a great day!
Tiny troll footnote: in Rust I could just slap `#[repr(C)] struct soo;` and be done 🦀😉.
https://redd.it/1k70puk
@r_cpp
I wanna know how this code compiles and runs. (constexpr, C++23)
Does std::vector<int> a
allocated, and filled (std::iota
) during compile time or run time? (C++23)
constexpr int n = 1e6; // 1'000'000
vector<int> a(n);
iota(a.begin(), a.end(), 1);
The above code is snippet of my solution to one of the problems on CodeForces.
https://redd.it/1k6w0dc
@r_cpp
Living in the future: Using C++26 at work
http://herbsutter.com/2025/04/23/living-in-the-future-using-c26-at-work/
https://redd.it/1k6jj54
@r_cpp
Declarative GUI toolkit - Slint 1.11 adds Color Pickers to Live-Preview 🚀
https://slint.dev/blog/slint-1.11-released
https://redd.it/1k5ws6o
@r_cpp
I already know C++ fairly well, should I start learning Python or JavaScript, or should I focus on C++ Data Structures & Algorithms (DSA)?
I'm not sure what I want to do now or later in career yet—I only learned C++ cuz it was part of my college curriculum. NOW ATLEAST I KNOW ONE PROGRAMMING LANGUAGE WHAT NOW
https://redd.it/1k5tv92
@r_cpp
Exploiting Undefined Behavior in C/C++ Programs for Optimization: A Study on the Performance Impact
https://web.ist.utl.pt/nuno.lopes/pubs.php?id=ub-pldi25
https://redd.it/1k5qbsb
@r_cpp
How to start making GUIs in C++
Hi everyone,
I'm writing this post because I'm working on a project (a simple CPU emulator) in C++ and I would like to code a basic GUI for it, but I'm pretty new to GUI programming, so I don't really know what I should use. The ways I've seen online are either Qt or Dear ImGui, but I don't if there are other good alternatives. So, can you please tell me what would you rather use for a project like this and, if you could, what should I use to learn it (documentation, tutorials, etc.)?
Thank you very much in advance
https://redd.it/1k5cqnn
@r_cpp
Learning C++ for Robotics & Autonomy Companies
Hello everyone!!
I'm an undergraduate student who transitioned to backend development about 7 months ago, primarily using Golang. During this time, I had the opportunity to interview with Waymo, Tesla, and a few other non-robotics/autonomy companies. I ultimately accepted an offer from Tesla to join their distributed systems team, working on the fleet of cars, IoT devices, and future Optimus robots at scale.
Most of my work will be in Go and TypeScript (with some frontend tasks), and a bit of Ruby. Interestingly, my mentor also mentioned I might work with some client-side C++ code, although it wasn't included in the job description. He said it shouldn't be a problem and that I’ll be fine.
Over the past 7 months, I've become really excited about the robotics and autonomy space in the U.S., particularly companies like Tesla, Waymo, Nuro, Aurora, Figure, Amazon Robotics, and others. While I'm still in college and thinking about my long-term career path, I’ve noticed that many Software Engineering roles at these companies — even on the backend or infrastructure side — often list C++ as a requirement. This includes teams focused on platform development, AI infrastructure, cloud systems, and more specialized areas like vehicle controls.
Since I want to continue growing in this field, I'm starting to realize how valuable C++ is; it seems to be used almost everywhere in this industry. So my question is: if I want to work and advance in this space, what's the best way to start learning C++ so that I could be valuable to many teams? Should I try building backend systems using C++? Or is most of the C++ work in these companies tied more to robot or vehicle control systems? My main area of expertise right now is distributed systems with Go, and I haven't encountered much C++ in that context and I am not very familiar with the language itself.
https://redd.it/1k5evqi
@r_cpp
Latest News From Upcoming C++ Conferences (2025-04-22)
This Reddit post will now be a roundup of any new news from upcoming conferences with then the full list being available at https://programmingarchive.com/upcoming-conference-news/
If you have looked at the list before and are just looking for any new updates, then you can find them below:
C++Now - 28th April - 2nd May
Last Chance To Buy Tickets For C++Now 2025 Which Starts Next Week
Full Schedule - [https://schedule.cppnow.org](https://schedule.cppnow.org)
Information About The Conference - https://cppnow.org
Registration - [https://cppnow.org/registration](https://cppnow.org/registration)
Pure Virtual C++ - 30th April
Full Schedule Announced \- The schedule includes talks from Inbal Levi, Hana Dusikova & Sinem Akinci - [https://developer.microsoft.com/en-us/reactor/events/25184/](https://developer.microsoft.com/en-us/reactor/events/25184/)
CppNorth - 20th - 23rd July
Early Bird Pricing Has Finished \- Regular tickets are still available to purchase at [https://store.cppnorth.ca/products/cppnorth-2025](https://store.cppnorth.ca/products/cppnorth-2025)!
CppCon - 13th - 19th September
Call For Speakers Now Open! \- Interested speakers have until May 11th to submit their talks with decisions expected to be sent out on June 22nd. Find out more including how to submit your proposal at [https://cppcon.org/cfs2025/](https://cppcon.org/cfs2025/)
C++ Under The Sea - 8th - 10th October
Call For Speakers Now Open! \- Interested speakers have until June 15th to submit their talks. Find out more including how to submit your proposal at [https://cppunderthesea.nl/call-for-speakers/](https://cppunderthesea.nl/call-for-speakers/)
Meeting C++ - 6th - 8th November
Call For Speakers Now Open! \- Interested speakers have until June 4th to submit their talks. Find out more including how to submit your proposal at [https://meetingcpp.com/meetingcpp/news/items/Submit-your-talks-to-Meeting-Cpp-2025-.html](https://meetingcpp.com/meetingcpp/news/items/Submit-your-talks-to-Meeting-Cpp-2025-.html)
C++Online
C++Online On Demand & Early Access Pass Now Available \- Purchase an early access pass for £25 which will give you early access to 25 talks and 7 lightning talks. Visit [https://cpponline.uk/registration](https://cpponline.uk/registration) to purchase
ACCU
Get Early Access To ACCU 2025 Conference Videos By Joining ACCU \- All ACCU members will be eligible to get Early Access to the YouTube videos from the 2025 Conference. Find out more about the membership including how to join at [https://www.accu.org/menu-overviews/membership/](https://www.accu.org/menu-overviews/membership/)
Anyone who attended the ACCU 2025 Conference who is NOT already a member will be able to claim free digital membership.
https://redd.it/1k59xjh
@r_cpp
Will C++26 really be that great?
From the article:
C++26, which is due to be launched next year, is going to change the C++ "game".
Citadel Securities' new coding guru suggests you need to get with C++26
https://redd.it/1k59uu8
@r_cpp
which cpp game framework would be best for making games for all platform?
Hi reddit community which framework would you guys suggest if the game had to be cross compiled to ios , android, web , mac , linux, windows
https://redd.it/1k4wov8
@r_cpp
Top 100 C++ Game Engines
https://terminalroot.com/top-100-cpp-game-engines/
https://redd.it/1k4gy1x
@r_cpp
A patchwork of Clang patches
https://cor3ntin.github.io/posts/clang21/
https://redd.it/1k4gtkz
@r_cpp
Announcing Traeger: A portable Actor System for C++ and Python
I have been working for several months on a personal project that I just published:
https://github.com/tigrux/traeger
It is an Actor System for C++ with bindings for Python, Go, and C.
It is written in C++ 17 for portability, with minimal use of templates to facilitate interoperability with other languages.
It is still in an early stage, but I think it provides the basics of the Actor Model:
1. Value semantics based on Immer.
2. Serialization (json, yaml, and messagepack).
3. Scheduler, Threadpool, Promises, Actors with mailboxes and messages (sequential for writers, concurrent for readers).
4. Network transparency based on ZMQ.
It has been tested on Ubuntu >= 20.04, MacOS >= 15.3 (for both x86_64 and arm64) and Windows 11.
Please take a look, experiment, and if you like it or find it interesting, give it a star.
Thank you in advance!
https://redd.it/1k3zbkn
@r_cpp
Candidate Boost Bloom library scheduled for review May 13-22
https://github.com/joaquintides/bloom
https://redd.it/1k3jzjy
@r_cpp
Zero-cost C++ wrapper pattern for a ref-counted C handle
Hello, fellow C++ enthusiasts!
I want to create a 0-cost C++ wrapper for a ref-counted C handle without UB, but it doesn't seem possible. Below is as far as I can get (thanks https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0593r6.html) :
// ---------------- C library ----------------
#ifdef __cplusplus
extern "C" {
#endif
struct ctrl_block { /* ref-count stuff */ };
struct soo {
char storageForCppWrapper; // Here what I paid at runtime (one byte + alignement) (let's label it #1)
/* real data lives here */
};
void useSoo(soo*);
void useConstSoo(const soo*);
struct shared_soo {
soo* data;
ctrl_block* block;
};
// returns {data, ref-count}
// data is allocated with malloc which create ton of implicit-lifetime type
shared_soo createSoo();
#ifdef __cplusplus
}
#endif
// -------------- C++ wrapper --------------
template<class T>
class SharedPtr {
public:
SharedPtr(T* d, ctrl_block* b) : data{ d }, block{ b } {}
T* operator->() { return data; }
// ref-count methods elided
private:
T* data;
ctrl_block* block;
};
// The size of alignement of Coo is 1, so it can be stored in storageForCppWrapper
class Coo {
public:
// This is the second issue, it exists and is public so that Coo has a trivial lifetime, but it shall never actually be used... (let's label it #2)
Coo() = default;
Coo(Coo&&) = delete;
Coo(const Coo&) = delete;
Coo& operator=(Coo&&) = delete;
Coo& operator=(const Coo&) = delete;
void use() { useSoo(get()); }
void use() const { useConstSoo(get()); }
static SharedPtr<Coo> create()
{
auto s = createSoo();
return { reinterpret_cast<Coo*>(s.data), s.block };
}
private:
soo* get() { return reinterpret_cast<soo*>(this); }
const soo* get() const { return reinterpret_cast<const soo*>(this); }
};
int main() {
auto coo = Coo::create();
coo->use(); // The syntaxic sugar I want for the user of my lib (let's label it #3)
return 0;
}
**Why not use the classic Pimpl?**
Because the ref-counting pushes the real data onto the heap while the Pimpl shell stays on the stack. A `SharedPtr<PimplSoo>` would then break the `SharedPtr` contract: should `get()` return the C++ wrapper (whose lifetime is now independent of the smart-pointer) or the raw C `soo` handle (which no longer matches the template parameter)? Either choice is wrong, so Pimpl just doesn’t fit here.
**Why not rely on “link-time aliasing”?**
The idea is to wrap the header in
# ifdef __cplusplus
\* C++ view of the type *\
# else
\* C view of the type *\
# endif
so the same symbol has two different definitions, one for C and one for C++. While this *usually* works, the Standard gives it no formal blessing (probably because it is ABI related). It blows past the One Definition Rule, disables meaningful type-checking, and rests entirely on unspecified layout-compatibility. In other words, it’s a stealth `cast` that works but carries no guarantees.
**Why not use** `std::start_lifetime_as` **?**
The call itself doesn’t read or write memory, but the Standard says that *starting* an object’s lifetime concurrently is undefined behaviour. In other words, it isn’t “zero-cost”: you must either guarantee single-threaded use or add synchronisation around the call. That extra coordination defeats the whole point of a free-standing, zero-overhead wrapper (unless I’ve missed something).
**Why this approach (I did not find an existing name for it so lets call it "reinterpret this")**
I am not sure, but this code seems fine from a standard point of view (even "#3"), isn't it ? Afaik, #3
C++26: more constexpr in the core language
https://www.sandordargo.com/blog/2025/04/23/cpp26-constexpr-language-changes
https://redd.it/1k6kh15
@r_cpp
How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
https://cookieplmonster.github.io/2025/04/23/gta-san-andreas-win11-24h2-bug/
https://redd.it/1k6g9gp
@r_cpp
Runtime formatting in CPP
I'm aware of there being a proposal to add runtime formatting in c++26. Is there a library supports runtime formatting in CPP. If not can someone please tell me the issues/problems of a runtime formatter?
https://redd.it/1k5vto2
@r_cpp
Views as Data Members for Custom Iterators, C++20*
https://www.cppstories.com/2025/custom_iter_cpp_20_ranges_views/
https://redd.it/1k5su6d
@r_cpp
Link-Time Optimization of Dynamic Casts in C++ Programs
https://web.ist.utl.pt/nuno.lopes/pubs.php?id=dyncast-pldi25
https://redd.it/1k5qg5t
@r_cpp
Anyone switch to C++ later in their development career?
If so, what language(s) did you come from? How did you make the switch?
I started as a C++ dev but switched to web stacks and haven't touched C++ in over a decade. I want to get back into it and was looking for some insights from anyone with similar experiences. Am willing to start as a junior dev again if that's what it takes!
https://redd.it/1k5hve3
@r_cpp
I started a dev blog about working on a native Twitch application using SwiftUI and C++
https://www.kulve.org/blog/tech_stack
https://redd.it/1k5cqx4
@r_cpp
SFML 3.0.1 is released!
https://github.com/SFML/SFML/releases/tag/3.0.1
https://redd.it/1k59g82
@r_cpp
I love Cplusplus
I have seen the pattern of influencer hating on CPP and I never understand their hate for CPP.
Many other great languages and it's really cool but cplusplus already does all of those things in one single unified language so yes there will be some complexity because your learning programming of any possible type not just a language. Why people doesn't make it clear and jump on hate train.
You will get loose when you start using pointers reference, try to accees data in certain ways but fundamentally stored in other way and few other things and these are source of early frustration with CPP but this is how it's suppose to be, not sure how any other language can fix this, they just lock you in a specific way so you don't venture on your own way and that is pathetic.
https://redd.it/1k4xp5p
@r_cpp
Why its showing error?
https://ibb.co/CKdZTwZm
https://redd.it/1k4w18h
@r_cpp
New C++ Conference Videos Released This Month - April 2025 (Updated to Include Videos Released 2025-04-14 - 2025-04-20)
**CppCon**
2025-04-14 - 2025-04-20
* Lightning Talk: What Does a CMake Developer Want From CMake? - Ben Boeckel - [https://youtu.be/-kUL4AFblCA](https://youtu.be/-kUL4AFblCA)
* Lightning Talk: What LLMs Won't Ever be Able to Do - Ben Deane - [https://youtu.be/km0JFBfFNJQ](https://youtu.be/km0JFBfFNJQ)
* Lightning Talk: C++ in the Cloud: One NIF at a Time with Elixir - Sakshi Verma - [https://youtu.be/5x9cYWt-BYM](https://youtu.be/5x9cYWt-BYM)
* Lightning Talk: The Present and Future of Cross-Platform GUI in C++ - Matt Aber - [https://youtu.be/p9LeAqoshkQ](https://youtu.be/p9LeAqoshkQ)
* Lightning Talk: Micro C++ Benchmarks & Murphy's Law - Lexington Brill - [https://youtu.be/4yu5PgDEhx8](https://youtu.be/4yu5PgDEhx8)
2025-04-07 - 2025-04-13
* Lightning Talk: C++ and Rust Bindings - Mixing It Best With CMake - Damien Buhl - [https://youtu.be/EcbmDXA4Inc](https://youtu.be/EcbmDXA4Inc)
* Lightning Talk: Every Use Case of Colon and Ellipses in C++ - Ali Almutawa Jr - [https://youtu.be/1blspAWnjUQ](https://youtu.be/1blspAWnjUQ)
* Lightning Talk: Do You Love or Hate Your C++ Build System? - Helen Altshuler - [https://youtu.be/jBnQ69ZMtHw](https://youtu.be/jBnQ69ZMtHw)
* Lightning Talk: Generative C++ - Alon Wolf - [https://youtu.be/y8NXF7WsSEc](https://youtu.be/y8NXF7WsSEc)
* Lightning Talk: Remote Execution Caching Compiler (RECC) for C++ Builds - Shivam Bairoliya - [https://youtu.be/oH1JKMKwDDA](https://youtu.be/oH1JKMKwDDA)
2025-03-31 - 2025-04-06
* Lightweight Operator Fusion Using Data-Centric Function Interfaces in C++ - Manya Bansal - [https://youtu.be/pEcOZDRXhNM](https://youtu.be/pEcOZDRXhNM)
* Security Beyond Memory Safety - Using Modern C++ to Avoid Vulnerabilities by Design - Max Hoffmann - [https://youtu.be/mv0SQ8dX7Cc](https://youtu.be/mv0SQ8dX7Cc)
* To Int or to Uint, This is the Question - Alex Dathskovsky - [https://youtu.be/pnaZ0x9Mmm0](https://youtu.be/pnaZ0x9Mmm0)
* Leveraging C++ for Efficient Motion Planning: RRT Algorithm for Robotic Arms - Aditi Pawaskar - [https://youtu.be/CEY4qRLcLmI](https://youtu.be/CEY4qRLcLmI)
* Guide to Linear Algebra With the Eigen C++ Library - Daniel Hanson - [https://youtu.be/99G-APJkMc0](https://youtu.be/99G-APJkMc0)
**Audio Developer Conference**
2025-04-14 - 2025-04-20
* Roland’s Holistic Approach to AI for Music Creation - Paul McCabe, Ichiro Yazawa & Kazuyoshi Sasamori - [https://youtu.be/ZvUGS754u5Y](https://youtu.be/ZvUGS754u5Y)
* Making Accessible Audio Software - Perspectives of a Blind Music Producer - Trey Culver & Adam Wilson - [https://youtu.be/JeyWnToyd1c](https://youtu.be/JeyWnToyd1c)
* Building a Plugin Assembly Line - The Road to Rapid Plugin Development - Bence Kovács & Linus Corneliusson - [https://youtu.be/Iwgd7ulJHa4](https://youtu.be/Iwgd7ulJHa4)
2025-04-07 - 2025-04-13
* Intro to Software Development of Audio Devices - From Plugins to Hardware - Wojtek Jakobczyk - [https://youtu.be/eqHaiV5uNnM](https://youtu.be/eqHaiV5uNnM)
* Teaching Audio Developers How to Build AI-Enhanced Audio Plugins - Matthew Yee-King - [https://youtu.be/Uy7BXe9crUM](https://youtu.be/Uy7BXe9crUM)
* Expanding SDKs and APIs in Pro Tools - Dave Tyler - [https://youtu.be/v31yooYnvYs](https://youtu.be/v31yooYnvYs)
2025-03-31 - 2025-04-06
* Workshop: Designing and Developing an AVB/Milan-Compliant Audio Network Endpoint - Fabian Braun - [https://youtu.be/Xs0UvCOjpnU](https://youtu.be/Xs0UvCOjpnU)
* JUCE and Direct2D - Matt Gonzalez - [https://youtu.be/7qepqLo5bGU](https://youtu.be/7qepqLo5bGU)
* Intro to Software Development of Audio Devices - From Plugins to Hardware - Wojtek Jakobczyk - [https://youtu.be/eqHaiV5uNnM](https://youtu.be/eqHaiV5uNnM)
**C++ Under The Sea**
2025-03-31 - 2025-04-06
* BJÖRN FAHLLER - Cache-friendly data + functional + ranges = ❤️ - [https://www.youtube.com/watch?v=QStPbnKgIMU](https://www.youtube.com/watch?v=QStPbnKgIMU)
https://redd.it/1k4gsi3
@r_cpp
Just dropped: TinyMCP - a C++ MCP SDK
Hey C++ developers!
After days of coffee-fueled coding sessions, we've released TinyMCP into the wild! It's our take on a C++ SDK for the Model Context Protocol (MCP) that lets your apps talk to AI assistants like Claude and Cursor.
## Why we made this
We built TinyMCP because our team needed a lightweight C++ solution that could:
- Run super fast (because who likes waiting?)
- Use minimal resources (your RAM will thank you)
- Work on different platforms without a fuss
- Play nicely with desktop applications (especially on Windows
## Perfect for desktop apps
This is especially handy if you're building desktop AI clients or tools because:
- Your users get snappy response times
- Everything can run locally if needed
- It's easy to integrate with existing C++ desktop applications
- Resource usage stays reasonable (no Chrome-level memory hogging)
## Give it a spin!
If you're curious about adding AI capabilities to your projects, swing by our GitHub repo: https://github.com/Qihoo360/TinyMCP
We're still ironing out some kinks, so any feedback, issues, or PRs would be awesome. And if you just want to give us a star to boost our morale, we wouldn't complain either! 😉
https://redd.it/1k4biyr
@r_cpp
Is fire'n'forget style asynchrony available via the STL alone?
I'm wrapping a C API with C++ and would prefer to not become a runtime beyond using what's already in the STL. (No global state beyond depending on libstdc++/vclib.) One API func supports setting a callback which is mandated to return promptly. If I wanted to provide a convenient interface to users to opt-in to long running callbacks which don't execute on the calling thread but asynchronously and sync using the API primitives, what are my options?
std::async returns a future which I either return to the user to hold on to and keep alive (while possible is "unnecessary" bloat), because its dtor waits for the async op. I'd need a preferably light weight manner to launch an async op without returning anything to the user or having to keep variables alive in my wrapper (in a global array, thread pool or whatever). I'd want the C++ runtime to carry out the async op as promptly as reasonably possible without a sync channel, which the async op takes on the onus to signal its completion.
https://redd.it/1k3jykt
@r_cpp
Error Handling
Hi, i have a question regarding error handling, I come from C# and Python where you generally just throw exceptions to build errror handling. Starting in c++ i have seen a lot of different opinions and solutions regarding error handling. I've seen people throwing exceptions everywhere and always, use error Code Systems or just doing none i guess. So my question would be what to use in certain situations. From my understanding so far you use Error Code Systems for Performance Critical Code. Exceptions should be used for more "high level" Programs and Tasks. Would this be right or am just completly wrong?
https://redd.it/1k3iyqv
@r_cpp