-
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
EBO + std::any can give the same address to different objects of the same type, a defect?
C++ requires different instances of the same type to have different addresses (https://eel.is/c++draft/basic#intro.object-10), which can affect the class layout e.g. when empty-base-optimization is involved, as the compiler will avoid placing the empty base at the same address as a member variable of the same type.
The same happens if the member variable is a std::variant with the base class as one of the alternatives: https://godbolt.org/z/js7e3vfK5 (which is interesting by itself, apparently this is possible because the variant uses a union internally, which allows the compiler to see the possible element types without any intrinsic knowledge of variant itself).
But this is NOT avoided for std::any (and similar classes) when it uses the small object optimization, which makes it possible to create two seemingly different objects at the same address: https://godbolt.org/z/Pb84qqvjs This reproduces on GCC, Clang, and MSVC, on the standard libraries of each one.
Am I looking at a language defect? This looks impossible to fix without some new annotation for std::any's internal storage that prevents empty bases from being laid out on top of it?
https://redd.it/1m3ug5z
@r_cpp
Is godbolt slow for you?
For many weeks now, godbolt has been extremely slow for me. Simple hello world frequently takes like 15 seconds to compile. It's so slow that I would say it's become nearly useless to me.
https://redd.it/1m3oprl
@r_cpp
I’m a teacher from Zambia creating free C++ tutorials for students – would love your feedback
https://youtu.be/dZabpjg2VGo?si=6Kg9829kZEQViCgW
https://redd.it/1m0t5k0
@r_cpp
Astronautical Calculator
https://github.com/YeahIamNickPap/Astronautical-Calculator/tree/Astronautics
https://redd.it/1m35ut5
@r_cpp
I was not able to answer why we need virtual functions in C++
I told the interviewer that if we need to call the dervied class function using base class pointer at runtime, then we need to have our base class function as Virtual. But interviewer asked "why not simple use dervied object pointer or dervied object to call that function? What's the use case for virtual functions?"
What answer was expected here?
can anyone explain this to me in really easy way with real world example if possible.
https://redd.it/1m2z8h9
@r_cpp
C++ Trailing Return Types
https://danielsieger.com/blog/2022/01/28/cpp-trailing-return-types.html
https://redd.it/1m2x4mp
@r_cpp
post-Sofia mailing
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/#mailing2025-07
https://redd.it/1m2ryzp
@r_cpp
Created tool that uses LLMs+profilers to automatically optimize code
Hey, I was working this summer on Functio - a tool to automatically do low-level optimizations of cpp code.. It uses profiling tools and language models to find and analyze bottlenecks and hotspots in your code, and then rewrites these critical parts to achieve better performance. Functio can invoke tools like perf utilities, static analyzers, LBR, analyze flamegraphs, and more, depending on context.
If you're working on performance-critical applications, I'd love to chat.
Short demo here
https://redd.it/1m2n57o
@r_cpp
Simple DOUBT
so i was making a lying half hourglass shape using c++ loops
ATTEMPT 1;
//printing upper half hourglass
\#include <iostream>
using namespace std;
int main() {
int w;
cout << "enter the base width (must be an odd number) : ";
cin >> w;
int m = (w+1)/2;
for(int i=0;i<m;i++) {
for(int j=0;j<i+1;j++) {
cout << "*";
}
for(int j=0;j<w-2*(i+1);j++) {
cout << " ";
}
for(int j =0;j<i+1;j++) {
cout << "*";
}
cout << endl;
}
}
ATTEMPT 2;
//printing upper half hourglass
#include <iostream>
using namespace std;
int main() {
int w;
cout << "enter the base width (must be an odd number) : ";
cin >> w;
int m = (w+1)/2;
for(int i=0;i<m;i++) {
for(int j=0;j<i+1;j++) {
cout << "";
}
for(int j=0;j<w-2(i+1);j++) {
cout << " ";
}
for(int j =0;j<i+1;j++) {
if(i==(m-1)) {
for(int k =0;k<m-1;k++) {
cout << "";
}
}
else {
cout << "";
}
}
cout << endl;
}
}
https://redd.it/1m2dej1
@r_cpp
Header file issues
Hi guys I’m working on my first larger C++ project building a central limit order book. The code worked fine until I split it into .h and .cpp files. I am new to this concept so would appreciate any help.
My repo is on GitHub: GitHub.com/JudeWallace/limit-order-book
The error is coming from OrderNode.h with the message:
error SelfTradePrevention does not name a type
SelfTradePrevention stpf = SelfTradePrevention::RTO
Also if you do look through my repo please tell me and better cpp ways
https://redd.it/1m26u35
@r_cpp
Early lessons from building a C++ foundation for engineering computation
Over the past few weeks I’ve been building the foundation for a computational system intended for engineering software. The first part I’m working on deals with 2D geometry: representing and computing curves, surfaces, and their relationships in a way that is robust, accurate, and maintainable.
Working on this has given me a much clearer picture of how critical the design decisions are when working in C++. Getting the abstractions right early enough to stay modular, while avoiding unnecessary overhead, is not easy—and it’s already forced me to rethink some of my first attempts.
One of the biggest challenges has been handling numerical stability without littering the code with special cases. I’ve leaned heavily on standard algorithms I’d seen before—Gauss-Kronrod quadrature, Horner’s method, Newton-Raphson, Aberth-Ehrlich—but adapting them to fit cleanly into a reusable, testable C++ module is a different challenge altogether.
I’ve been cautious about over-engineering at this stage, but also don’t want to back myself into a corner later. So far, focusing on clear interfaces and keeping state as isolated as possible has helped.
For those of you who’ve built C++ libraries of significant size: how do you approach finding the right level of abstraction early in a project, when it’s still unclear what the eventual direction will be?
https://redd.it/1m1hzu6
@r_cpp
The Best C++ Library
https://mcyoung.xyz/2025/07/14/best/
https://redd.it/1m17npu
@r_cpp
C++ Refactoring Tools Test Suite
https://github.com/LegalizeAdulthood/refactor-test-suite
https://redd.it/1m13gnk
@r_cpp
Struggling to progress
Recently i have been struggling with learning cpp , Everytime i try to code something the code is too complex even if i make chatgpt simple and if i try to code without chatgpt i go days trying to piece together until i ask chatgpt for help it is hard everytime i look at code it looks complex and its like something i have never seen before except for the std::cout or return in the functions when i try to build up on a project i struggle to find anything to implement my repo: https://github.com/Jilio013/Basic-Tokenizer.git
https://redd.it/1m0xkex
@r_cpp
How I found a $200k C++ Dev job
I realized many roles are only posted on internal career pages and never appear on classic job boards.
So I built an AI script that scrapes listings from 70k+ corporate websites.
Then I wrote an ML matching script that filters only the jobs most aligned with your CV, and yes, it actually works.
You can try it here (for free).
(If you’re still skeptical but curious to test it, you can just upload a CV with fake personal information, those fields aren’t used in the matching anyway.)
https://redd.it/1m0yf2b
@r_cpp
Looking to Contribute to C++ and Embedded Projects
Hi,
I'm an enthusiastic developer with a strong interest in C++ and embedded systems, and I'm looking to contribute to open-source projects in these areas. I’m comfortable with microcontrollers, low-level programming, and hardware interfaces, and I’m eager to learn more by collaborating with experienced developers.
I’d love to help with bug fixes, feature development, documentation, or testing—whatever is needed.
If you have any projects that could use an extra pair of hands, or if you can point me toward something active and beginner-friendly, I’d be very grateful.
Thanks in advance!
https://redd.it/1m3sztl
@r_cpp
TRACTOR: Translating All C to Rust
https://www.darpa.mil/research/programs/translating-all-c-to-rust
https://redd.it/1m3i0ui
@r_cpp
IWQt ( iwd applet for Linux systems )
Hey, posting for some feedback and maybe to help someone that's been looking for a similar tool.
It's an iwd applet made with qt to help replace NetworkManager on lightweight Linux systems
https://github.com/fingu/iwqt
https://redd.it/1m3aaig
@r_cpp
Need Guidance for C++ Dev Role Interview
Hello Everyone, I was looking for guidance for my interview on this 24th 🙏.
The company(GoQuant) is a digital asset trading infrastructure provider. The company focuses on delivering high-performance market data and execution services to leading financial institutions.
I will be getting interviewed for C++ Developer Intern role. I want to know what kind of specific things I can prepare for it. Please ,anyone with experience in tech roles of HFT or finance companies,I need help.
This can be my first corporate experience 🥺.Help
https://redd.it/1m34kuf
@r_cpp
What do you think about QT as a GUI library?
I wanted to start a graphical project and idk much about GUIs.
https://redd.it/1m2pyl2
@r_cpp
Error when running project
I am rather new to C++ and was wanting to learn it for some future projects. I'm relatively self taught in most languages so I haven't gotten professional experience with setting up C++. I've been having an issue where when running the file an error message pops up complaining about
"launch: program 'C:\\Users\\Name\\Desktop\\LearningC++\\Project1.exe' does not exist"
I was told that this is a compiler issue so I followed a tutorial which included installing a compiler called minGW. (Video:https://www.youtube.com/watch?v=DMWD7wfhgNY)
Before I start doing anything big I would like to have the ability of running a 'Hello World' project first 😂. Does anyone know any solutions to this problem?
https://redd.it/1m2vq71
@r_cpp
Need to know improvements for my memory pool!!
So here's the thing around 2-3 months before I made a memory pool in C it was taken from a research paper by Ben Kenwright it talks about how to implement a fixed size memory pool without any loop overhead!! A small help ... can you guys please review it or you can contribute or what improvements can I work on.. beside that you guys can contribute to my code to make it more useful for real life use-cases(its kind of my dream :) ) !!!
link: https://github.com/ankushT369/cfxpool
https://redd.it/1m2rdrf
@r_cpp
i am kinda stuck! what should i do next? have the projects i made has any significance?
https://github.com/Akshat227
https://redd.it/1m2eawr
@r_cpp
C++ Projects: Level 1 to 10 Progression
https://claude.ai/public/artifacts/dccfed83-ecd8-4b76-b89f-4dbb4a180513
https://redd.it/1m27rah
@r_cpp
mess up computer
im new to this and i want to build software for the system and maybe replicas os word processors and other tools.
im just wondering that if i attempt to make something and it ends up being bad wll it destroy my computer interface or fuck up the memory. and what is the likely hood if so
https://redd.it/1m1w5ey
@r_cpp
Three Ways For C++ Thread Synchronization in C++11 and C++14
https://chrizog.com/cpp-thread-synchronization
https://redd.it/1m1eovt
@r_cpp
C++26: std::format improvements (Part 2)
https://www.sandordargo.com/blog/2025/07/16/cpp26-format-part-2
https://redd.it/1m156ij
@r_cpp
I built an authoritative network stack...
I released it free under the MIT License.
The latest version is a debug-only static library — for now.
This is the real backbone behind RiftForged — a game that doesn’t lie to its players and doesn’t fake sync.
It handles reliable UDP, encryption, compression, and RTT/RTO estimation at scale.
What you’re seeing in the gif below is 6,000 client threads simulating movement with full encryption and packet-level reliability.
I built it from raw socket I/O — no ENet, no RakNet, no QUIC.
https://github.com/TheToastiest/RiftNet
https://giphy.com/gifs/H87nMPSkLCvOZ71sz0
https://redd.it/1m0z5g9
@r_cpp
I want to start programming in C++ (I've never programmed)
Today I decided that I want to study programming and I'm interested in c++, but I don't really know where to start, I don't even know what I should download. Could anyone help me with how to take this initiative and whether I should start in C++ or another language?
https://redd.it/1m0zk3d
@r_cpp
Show "rodata" section in Compiler Explorer IDE mode?
When I compile a single file in Compiler Explorer I can see all the constants like string literals in the output window.
const char* ss = "abcdef";
.LC0:
.string "abcdef"
mov rbx,QWORD PTR [rip+0x2ee0] # 404018 <ss>