r/cpp_questions 7h ago

OPEN Is there any reason to use std::reinterpret_cast?

5 Upvotes

I know that std:: reinterpret_cast is used by people to cast the bits of an object of type T1 to an object of type T2, while retaining the exact bits. However, as far as I know this triggers UB. Before C++20 and std::bit_cast, we could std::memcpy the objects to avoid UB, and after C++20, we can use std::bit_cast. Given this, I don't see any legitimate reason for why one might need std::reinterpret_cast. If so, why hasn't this feature been deprecated yet?


r/cpp_questions 19h ago

OPEN How much do you rely on tooling for C++ memory safety?

8 Upvotes

Hey everyone,

I've been thinking about the whole memory safety discussion lately, especially with all the push toward memory-safe languages.

C++ has gotten a lot better with things like RAII, smart pointers, std::span, etc., but in larger/older codebases it still feels pretty easy to end up with memory bugs. At some point you can have all the modern C++ practices in place and still have something nasty slip through.

For people working on production C++:

  • How much do you actually rely on tools like ASan, UBSan, Clang-Tidy, static analysis, etc.?
  • Do you have a strict subset of C++ that people are expected to follow, or is it mostly code review + guidelines?
  • Are things like the Core Guidelines safety profiles or Safe C++ starting to have any practical impact where you work?
  • And has memory safety ever been enough of a concern to justify rewriting a component in a memory-safe language?

I'm mostly interested in what actually works in practice. It's easy to talk about memory safety in theory, but I'm curious what teams are doing day to day in real C++ codebases.


r/cpp_questions 4h ago

OPEN Is it worth learning another language besides C++?

34 Upvotes

C++ is the only general-purpose language with which I am most familiar, I tried to learn other languages like C# or Rust, but without a clear idea of what to do with those tools, it's more difficult to learn them.

And all the software I use uses or is written in C++, specifically Godot Engine, Blender, LMMS, that's why I always have ideas of what to do with C++.

learncpp.com is amazing and possibly one of the best educational resources for a language in general, either that, or I have Asperger's and they have to explain everything to me in simple terms.

My question is, if this limits me in the long run as a programmer or should I learn an additional language that works well with C++?, I personally wouldn't trust a programmer who claims to know 15 technologies; someone who tries to do too much often accomplishes little, but that's just a personal opinion, what do you think?.


r/cpp_questions 10h ago

OPEN Feel stucked in skill improvement

0 Upvotes

Hi everyone!
What can I do if I feel that I don't improve my skill on current work. I mean, when I've just started learning C++, there was a lot of information for me and I felt really tired after a working day. But after year or two, I've learned about basics (pointers, OOP, containers in std and some patterns) and now I just applying this knowledges on my work. But I'm sure there is a lot of information to learn. Because my work doesn't need this, I feel like my skill doesn't grow up for a year or something about. What books or what sites can u recommend not for newbees to read or practice?


r/cpp_questions 7h ago

OPEN I'm learning c++ so I have a question, am I supposed to use brace initialization over the = initialization, if so when? I can't decide for myself

12 Upvotes
int x{2};
int x = 2;

r/cpp_questions 16h ago

OPEN Making part of the program run separately

2 Upvotes

Hi everybody,

I have been recently trying to make a complete project and I decided to go with a small project, a clipboard manager.

My problem is that I want the code that tracks clipboard changes to run separately form the program itself (whether it was opened or closed).

I tried searching on Internet and asking AI but I did not get the answer I am looking for.

Currently I have two parts I need start_clipboard_monitor that takes care of tracking clipboard changes and start_app that take care of the program ui.

My question is how to make start_clipboard_monitor run independently from the program and how to make it run in background?


r/cpp_questions 4h ago

OPEN I'm looking for a AST based cli tool to rename symbols in C++ codebases

2 Upvotes

I want to change existing struct names from snake_case to PascalCase etc. I have a compilation dB and clang tooling. I want to rename one struct from the cli.

How can I do that?


r/cpp_questions 9h ago

OPEN How much C++ is enough for getting into Game Development?

15 Upvotes

Hi guys,

I know this question about starting out as a complete noob has been asked and answered numerous times… but my question does have a bit of a twist to it.

How and where do I start learning C++, specifically for rolling into a game engine like Unreal Engine later on? I understand UE C++ is modified a fair bit compared to regular C++, and that I don’t have to become a C++ expert in order to make a game.
As far as I’m aware the hybrid C++ & Blueprint approach is the most efficient way to develop, I don't want to rely solely on Blueprints anyways.

My goal is simply to grasp the core understanding of C++ so I can optimize my game down the road and fix things easier.

I initially wanted to start out with the beloved Bucky’s (thenewboston) C++ tutorial, but as good as it is, people say it’s outdated. Now I’m shifting my focus to learncpp.com.

Until what chapter do you guys think I should learn C++ (the basics and most important parts for game dev) with my end goal in mind?

My end goal is making my own indie horror game, a passion project, not a job I would live off of.
I’ve seen comments saying Chapter 12, and that mostly everything beyond that would have diminishing returns or no real-world use for me.

My Plan:
Learn C++ basics -> Learn the most important parts specifically for Unreal Engine and Game Optimization -> Test games in C++ alone -> Trial and error -> Move over to learning Unreal Engine.

Any help is greatly appreciated!

Important edit: completely forgot to mention, I’m currently on a 1 year internship away from my home setup (10 months left) and all I have currently is a T480 which I used so far mostly for story-writing and planning so I can’t just jump into Unreal Engine.
Just figured might as well learn some C++ basics until I return home and buy a beefy setup and be a little bit more prepared to jump into Unreal Engine.


r/cpp_questions 7h ago

META Coroutines

7 Upvotes

Just started reading about coroutines, as the company I recently started working for uses them; this is my first encounter of them. I’m a long time user of threads, bear with me, it’s all new territory.

I know I have only just scratched the surface, but I’m trying to understand the use case. One thing I think I have straight is:

Threads don’t really need to know anything about other threads, except when they have to share resources (mutex and semaphores) or pass data (IPC), but coroutines need to know there are other routines and to only take baby steps, then let other coroutines run.

Is this a start?