/r/cpp
Discussions, articles and news about the C++ programming language or programming in C++.
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
/r/cpp
I'm really enjoying learning C++ but not sure taking a udemy course can help me be employable.
I need to get proper trianing and build real projects, any recommendations?
Thank you.
I hear a lot that C++ is not a suitable language for data analysis, and we must use something like Python. Yet more than 95% of the code for AI/data analysis is written in C/C++. Let’s go through a relatively involved data analysis and see how straightforward and simple the C++ code is (assuming you have good tool which is a reasonable assumption).
Suppose you have a time series, and you want to find the seasonality in your data. Or more precisely you want to find the length of the seasons in your data. Seasons mean any repeating pattern in your data. It doesn’t have to correspond to natural seasons. To do that you must know your data well. If there are no seasons in the data, the following method may give you misleading clues. You also must know other things (mentioned below) about your data. These are the steps you should go through that is also reflected in the code snippet.
As I said above this is a rather involved analysis and the C++ code snippet is as compact as a Python code -- almost. Yes, there is a compiling and linking phase to this exercise. But I don’t think that’s significant. It will be offset by the C++ runtime which would be faster.
using DT_DataFrame = StdDataFrame<DateTime>;
DT_DataFrame df;
df.read("IcecreamProduction.csv", io_format::csv2);
// These parameters must be carefully chosen
//
DecomposeVisitor<double> d_v {
180, 0.08, 0.0001, decompose_type::additive
};
df.single_act_visit<double>("IceCreamProduction", d_v);
const auto &trend = d_v.get_trend();
auto &data = df.get_column<double>("IceCreamProduction");
// Optional: take the trend out
//
for (std::size_t i { 0 }; auto &datum : data)
datum -= trend[i++];
// Optional: Differencing to take serial correlation out
//
double prev_val { data[0] };
for (auto &datum : data) {
const double tmp = datum;
datum -= prev_val;
prev_val = tmp;
}
data[0] = data[1];
fft_v<double> fft;
df.single_act_visit<double>("IceCreamProduction", fft);
// We assume the time series is per one unit of time
//
constexpr double sampling_rate = 1.0;
const auto &mags = fft.get_magnitude();
double max_magnitude = 0.0;
std::size_t dominant_idx = 0;
for (std::size_t i { 0 }; i < mags.size(); ++i) {
const double val = std::fabs(mags[i]);
if (val > max_magnitude) {
max_magnitude = val;
dominant_idx = i;
}
}
const double dominant_frequency =
double(dominant_idx) * sampling_rate / double(mags.size());
const double period = 1.0 / dominant_frequency;
std::cout << "Max Magnitude: " << max_magnitude << std::endl;
std::cout << "Dominant Index: " << dominant_idx << std::endl;
std::cout << "Dominant Frequency: " << dominant_frequency << std::endl;
std::cout << "**Period**: " << period << std::endl;
Every library needs to be included, built in 1 of 5 completely different ways, or its binaries downloaded, how do you guys keep track of all of these things? Setting things up takes up hours of frustrating error hunting and by the end I'm too exhausted to work on my actual project.
Am I missing something? Am I just not built for this?
Use this thread to share anything you've written in C++. This includes:
The rules of this thread are very straight forward:
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/1hrrkvd/c_show_and_tell_january_2025/
A new release of the legendary sqlite_orm library! 🚀
This is a minor release—no uber features, but compared to other minor releases, this one is the least minor of all the minor ones!
Now, let’s go over the new features:
• New drop functions: storage.drop_table_if_exists, storage.drop_index_if_exists, and storage.drop_trigger_if_exists for those who needed alternatives to storage.drop_table, storage.drop_index, and storage.drop_trigger.
• Two new pragma fields: locking_mode and max_page_count.
• More convenient API for declaring FOREIGN KEY constraints when working with inherited mapped structures. Instead of writing:
foreign_key(&Classroom::student_id).references(column<Student>(&Base::id))
you can now write a shorter version:
foreign_key(&Classroom::student_id).references<Student>(&Student::id)
• CTE support for CRUD operations.
• Overloaded bitwise operators and unary minus.
• New example in the examples folder: any.cpp—a powerful demonstration of how to bind std::any to SQLite using sqlite_orm, allowing operations on std::any without additional serialization.
• VSCode integration: Added .vscode folder with preconfigured settings. Now, if you’re contributing to sqlite_orm, you can execute important actions directly from VSCode using Command Palette → Run Task. You can trigger formatting, run the amalgamation script, and execute unit tests right from your IDE!
• Optimized serialization: Removed unnecessary parentheses—fewer bytes mean lower memory consumption.
• More constexpr functions for better compile-time evaluation.
• Bug fixes & improvements: 4 bugs fixed + 3 important refinements applied.
Enjoy the update! 🚀✨
CppCon
2025-01-27 - 2025-02-02
Audio Developer Conference
2025-01-27 - 2025-02-02
For those interested in exploring concurrency or micro-benchmarking, I’ve developed a c++ library that includes a collection of concurrent data structures/sync primitives. Additionally, it features a dedicated benchmarking branch with all the necessary submodules preconfigured, easy to dive into micro-benchmarking against boost right away. This Wiki is good place to start.
Any feedback/criticism is welcome.... contributions as well.
I have been doing a lot with robotics developement recently, ROS to be more percise, but my issue is I never really learned or worked with C++. I went through the learncpp.com and some other cpp learn site, but I would really love to learn through some projects, but I have no idea where to start. Does anyone have any good recommendations for where could I learn C++ throughout small projects and tasks? Preferably with solutions or code explanations alongside to give me a bit of guidance on how things should be. I intend to move onto working with openCV in the future and maybe even embedded systems on the long run. Thanks!
I developed a logger in C++23 and I need opinions so I can make it better, any feedback would be very appreciated!
I like the idea of concepts. Adding compile time checks that show if your template functions is used correctly sounds great, yet it feels awful. I have to write a lot of boilerplate concept code to describe all possible operations that this function could do with the argument type when, as before, I could just write a comment and say "This function is called number_sum() so it obviously can sum only numbers or objects that implement the + operator, but if you pass anything that is not a number, the result and the bs that happens in kinda on you?". Again, I like the idea, just expressing every single constraint an object needs to have is so daunting when you take into account how many possibilities one has. Opinions?
Some of the embedded courses require you to have particular MCUs, kits etc.
What if you only have a good laptop and that's it? I'll be able to get STM32/raspberry pi after 3 months, but for the first 3 months, I'd like to just learn C++ that will be helpful to me later as an embedded programmer. My embedded goals would be knowing how to write STM32 code, write linux drivers for various cameras, audio codecs, sensors, display stuff etc.
I already have Visual studio, but also have ubuntu installed as a second OS, so pretty flexible here. Right now I'm learning about assembly (just to get a feel of what happens under the hood).
I know a little bit of python, and already know basics of C (pointers, loops, structs etc).
I know Ritchie's book is getting recommended, but I wish there was a resource that would allow me to build a project. Like to put to use my C++ skills right away, so to speak. Again, this is for junior level for now.
After working on this project for so long, I've done it! importizer v1.0.0 is out today.
Ready to switch from header-based code to the power of C++20 modules? Importizer makes the transition simple and fast, saving you time and effort!
Two Modularization Options:
After running, just choose what to export, and your project is ready for use again. Transitional modularization will break very little to the header-based project, while providing a module interface for C++ module users.
Try it out on your codebase today! Let me know if it works!
Two months ago was the C++ Committee meeting, in Wrocław, Poland 🇵🇱, and the work on C++26 is ongoing!
The features voted on will be added gradually to the working draft, and will likely be officially released on the next C++ version (C++26), barring any subsequent changes. This was one before the last meeting for forwarding C++26 features.
The meeting site was lovely, with the beautiful Wroclaw market, museum, river, parks and Racławice panorama were all within walking distance.
The hotel was convenient, and the meeting organizers ran the meeting well. The hybrid (on-site/online) experience worked as expected. We appreciate that greatly!
We will continue operating hybrid meetings going forward.
Main C++26 Features approved in Wrocław: 🎉
This week was dedicated to papers which might plausibly affect C++26.
match
Expression — encouraged to come backis
and as
— no consensus
EWGI discussed 10 papers over the entire Friday of the meeting with the intent of preparing them for presentation in EWG. Of the 10:
4 Were determined to have sufficient motivation and paper readiness to be seen by EWG, and were forwarded. All were given feedback on how to improve presentation for EWG.
4 Were given extensive feedback on how to improve the paper motivation, presentation, and contents, and had sufficient consensus to return to EWG. Of those, 1 had very weak consensus to return.
2 were discussed extensively, and after discussion, determined to have insufficient motivation to continue or be seen again, but of course are welcome to come back with improved motivation.
CWG met during the full week, and reviewed 34 issues, and 17 papers, including “Reflection” and “contracts”.
LEWG met during the full week, and reviewed multiple features for C++26. The main features that captured our time were:
std::uninitialized
)write_env
and unstoppable
Sender Adaptorsindirect
and polymorphic
(Merged into P3019R11)
Unfortunately, we did not have any Policies discussion during Wroclaw, we will see them again in upcoming meetings.
Information about policies can be found in: “P2267R1: Library Evolution Policies (The rationale and process of setting a policy for the Standard Library)”.
Worth noting that Evolution Work Group (EWG) have also introduced policies, and have accepted: “SD-10: Language Evolution (EWG) Principles” during Wroclaw.
In addition to the work meeting, we had two evening sessions during the week (initiated by WG21 members). Evening sessions are informative sessions, during which we do not take any binding votes.
They are meant for either reviewing topics relevant to the committee in more depth than possible during the work sessions (such is the case for "Relocatability") , or for introducing topics which are not procedurally related but are relevant to WG21 (such is the case for “Perspectives on Contracts").
Thank you to all our authors and participants, for a great collaboration in a productive and useful review process, and see you (in-person or online) in Hagenberg!◝(ᵔᵕᵔ)◜
LWG met in person throughout the week and reviewed multiple papers.
Note: List also contains papers forwarded but not add to plenary this time (either as require review from other group, finalize wording fixes, or minor changes)
(See: A list of LWG issues seen by LEWG)
Note: Issues finalized during a meeting are tentatively ready but voted on during the next meeting (in this case, Hagenberg).
Networking Study Group did not meet in person during Wroclaw. We hold telecons as required. Our main focus is on Networking proposals based on P2300.
The numerics group met on Monday and Tuesday, we talked about floating-point for a total of one complete day. We had few people in the room and a few online for a minimum of our quorum of 6.
SG6 additionally met in joint session with LEWGI (SG18) for another total of a complete day. Refer to the Library Evolution Working Group Incubator Study Group (SG18) Progress above.
P3161R2: Unified integer overflow arithmetic — A few changes were requested but otherwise the paper was considered ready for LEWG.
P3348R1: C++26 should refer to C23 not C17 — We requested that the <cmath>
parts of C23 are processed via their own paper, so that the remaining parts of P3348 can make quicker progress.
P3307R0: Floating-Point Maximum/Minimum Function Objects — We encouraged further work. However, if we could pass function templates / function overload sets easily that problem wouldn't even need solving.
P3397R0: Clarify requirements on extended floating point types — see below
P3375R1: Reproducible floating-point results — see below
P3488R0: Floating-Point Excess Precision (CWG2752 Excess-precision floating-point literals) — see below
P3479R0: Enabling C pragma support in C++ — see below
We clarified our expectations of floating-point behavior for the extended floating-point types and determined that we need to implement behavior-changing attributes of the floating-point standard before we can do anything helpful. This became a recurring theme for the four papers listed above. Note, however, that we agreed on not solving this via pragmas.
SG7 met for 1.5 days during Wroclaw, and saw the following proposals.
SG9 met in Wrocław on Monday and Tuesday. We also had a special session with weak quorum on Wednesday morning due to a last-minute room availability opportunity.
We forwarded five papers to LEWG—two for parallel range algorithms and three for SIMD. We requested revisions of three other papers, including one on range type-erasure, one on a generalized checked-access (at) mechanism, and one on a range adaptor for lazy scan. We also provided informal feedback to a paper on the ranges-related features of the Unicode in the Standard Library paper targeting C++29.
Depending on LWG’s workload, they could all make it into C++26.
We expect them all to come back for C++29.
SG14 did not meet during the Wroclaw meeting. We continue to hold monthly telecons to discuss low latency, gaming, and embedded related papers.
SG15 have met for 1.5 days during Wroclaw. SG15 focused on both C++ IS targeting papers (such as Profiles and Contracts) as well as papers for the new Ecosystem IS (which was also discussed during this meeting, see below), planned to be developed parallelly to the C++ Standard.
P3470R0: Interface-Unit-Only Module Library Support
SG16 did not meet in person during Wroclaw.
SG21 met for 1 day (Fri) in Wroclaw. We also continue to hold weekly telecons.
this->
to minimise the probability of accidentally referring to a member outside of its lifetime.
SG22 did not meet in person during Wroclaw. We continue to run telecons by demand and provide feedback through the mailing list.
SG23 met for 2.5 days in total (Tue PM, Wed, Thu) during Wroclaw.
NOTE: This is a plan not a promise. Treat it as speculative and tentative.
See P1000, P0592, P2000 for the latest plan.
Meeting | Location | Objective |
---|---|---|
2024 Fall Meeting | Wrocław 🇵🇱 | C++26 major language feature freeze. |
2025 Winter Meeting | Hagenberg 🇦🇹 | C++26 feature freeze. C++26 design is feature-complete. |
2025 Summer Meeting | Sofia 🇧🇬 | Complete C++26 CD wording. Start C++26 CD balloting ("beta testing"). |
2025 Fall Meeting | Kona 🇺🇸 | C++26 CD ballot comment resolution ("bug fixes"). |
2026 Winter Meeting | 🗺️ | C++26 CD ballot comment resolution ("bug fixes"), C++26 completed. |
2026 Summer Meeting | 🗺️ | First meeting of C++29. |
2026 Fall Meeting | 🗺️ | Design major C++29 features. |
2027 Winter Meeting | 🗺️ | Design major C++29 features. |
2027 Summer Meeting | 🗺️ | Design major C++29 features. |
2027 Fall Meeting | 🗺️ | C++29 major language feature freeze. |
NOTE: This is a plan not a promise. Treat it as speculative and tentative.
IS = International Standard. The C++ programming language. C++11, C++14, C++17, C++20, C+23, etc.
TS = Technical Specification. "Feature branches" available on some but not all implementations. Coroutines TS v1, Modules TS v1, etc.
CD = Committee Draft. A draft of an IS/TS that is sent out to national standards bodies for review and feedback ("beta testing").
Updates since the last Reddit trip report are in bold.
Feature | Status | Depends On | Current Target (Conservative Estimate) | Current Target (Optimistic Estimate) |
---|---|---|---|---|
Senders | Plenary approved | C++26 | C++26 | |
Networking | Require rebase on Senders | Senders | C++29 | C++26 |
Linear Algebra | Plenary approved | C++26 | C++26 | |
SIMD | Plenary approved | C++26 | C++26 | |
Contracts | Forwarded to CWG, LWG | C++29 | C++26 | |
Reflection | Forwarded to CWG, LWG | C++26 | C++26 | |
Pattern Matching | EWG (discussed in Wroclaw) | C++29 | C++26 | |
Profiles, Syntax | EWG (discussed in Wroclaw) | C++29 | C++26 |
Last Meeting's Reddit Trip Report.
If you have any questions, ask them in this thread!
Report issues by replying to the top-level stickied comment for issue reporting.
/u/InbalL, Library Evolution (LEWG) Chair, Israeli National Body Chair
/u/jfbastien, Evolution (EWG) Chair
/u/erichkeane, Evolution Working Group Incubator (SG17, EWGI) Chair, Evolution (EWG) Vice Chair
/u/hanickadot, Compile-Time programming (SG7) Chair, Evolution (EWG) Vice Chair, Czech National Body Chair
/u/ben_craig, Library Evolution (LEWG) Vice Chair
/u/c0r3ntin, Library Evolution (LEWG) Vice Chair
/u/foonathan, Ranges (SG9) Vice Chair
/u/V_i_r, Numerics (SG6) Chair
/u/bigcheesegs, Tooling (SG15) Chair
/u/tahonermann, Unicode (SG16) Chair
/u/mtaf07, Contracts (SG21) Chair
/u/timur_audio, Contracts (SG21) Vice Chair
/u/je4d, Networking (SG4) Chair
... and others ...
Is understanding Include files of say STL containers in /usr/include/ to get exposed to and be able to write good cpp a genuine way to do so as I haven't seen anyone recommend that.
Should I go after every include header file or just the most important ones and that will be a good enough start ?
I'm a web developer and I was very fed up with the overall Javascript ecosystem so last month I decided to take a small break from this entire JS world and explore something, I chose C++ solely because its one of my academic subject and I thought going slightly mid/low level would make me a better dev and make me understand the fundamentals since the JS V8 is built on C++ itself. I learnt most of the basic syntax and fundamentals about it and loved it so far.
I want to create 3-5 small/mid level projects using it for my own sake so can y'all suggest me some projects you think that'll be good and maybe impressive enough to showcase in my portfolio site.
PS: if possible something related to web, I don't like game dev so don't suggest it pls :!
Hello, i have been working on an open source dynamic system simulator for a while now emscripten build: https://dynamicsimulator-beta.static.domains/ , demo: https://youtu.be/xRRwlTSGhQI . github repo: https://github.com/ahmed-AEK/Simple_Dynamic_Simulator, mostly aimed as an educational tool for systems courses (that doesn't cost an arm and a leg). I am mostly looking for feedback and things to improve to make it more useful to people.
Also is there any better place to post it that i may get more feedback ?
Over the top of my head i think having a variable workspace and adding a scripting language (i am thinking lua) would be the next step.
I am mostly relying on sdl so that i can make a webassembly and mobile releases in the future.
What do you guys think ?
Hey everybody!
Let me introduce you to SimpleBLE, a cross-platform Bluetooth library specifically designed for use in all kinds of environments with a very simple API that just works, allowing developers to easily integrate it into their projects without much effort, instead of wasting hours and hours on development.
Among our latest new features is now full support for Android! You can now develop your SDK or applications and add Bluetooth functionality across all major mobile and desktop operating systems!
We provide comprehensive functionality support for BLE Central mode, enabling developers to scan and discover nearby BLE devices, handle pairing and connection management of peripherals, and interact with GATT characteristics and descriptors just to name a few. This functionality is fully supported across Windows, Linux, MacOS, iOS and Android, using our language bindings for C, C++ and Python, with a lot more coming soon.
We also have a preview for BLE Peripheral mode, letting you turn any compatible Linux system into a custom Bluetooth peripheral.
See for yourself how easy it is to get started by looking at our examples on GitHub.
SimpleBLE is licensed under the Business Source License 1.1 and is trusted by industry leaders across healthcare, automotive, manufacturing, and entertainment. While commercial use requires a license, SimpleBLE is free to use for non-commercial purposes and we gladly offer free licenses for small projects, so don't hesitate to reach out!
Want to know more about SimpleBLE's capabilities or see what others are building with it? Ask away!
I hate rust language, but love the tooling. I like Modern* C++ language more than Rust, but absolutely hate the tooling. Curious if the Rust Gang hype is actually legitimate or not with the robotics industry or should I stick to my guns with Python and C++?
I don't have issues learning new tech, its just part of the job. But I really don't want to waste my time if there isn't any actual momentum beyond hobby projects and C++ is being used more often beyond legacy code.
* Utilizing the newer features of C++ such as shared pointers and other features designed to make it easier to avoid memory leaks.
The other trending rant post made me curious what is the current widely used package manager and deps resolution.
Let say you use CMake, but need to add some libraries which have their own deps tree. It's possible two libraries require same dependency but with different version tha breaks ABI compatibility.
For personal project I'm a fan of vcpkg in manifest mode.
It just works™️ and setup is pretty straightforward with good integration in major IDEs. Vcpkg.io contains all libraries that I probably ever need.
At work we use Conan since it has good integration with our internal Artifactory.
I'm not fan of the python-dependant recipe in v2.0, but I but I see concrete benefit on enforcing the compliance yada-yada, since approved 3rd party package can just be mirrored, and developers can pull a maintained conan profile containing compiler settings, and cpp standard, etc.
I have been trying to "ignore" other option such as Spack, Hunter, and Buckaroo, but now I'm curious: are they any better?
What about cmake own FetchContent_MakeAvailable()'
?
Non-exhaustive list:
Note: No flamewar/fanboyism/long rant please (short rant is OK lol) . Stick with technical fact and limit the anecdote.
If you don't use package manager that's fine, then this discusion isn't interesting for you.
Just to be clear, this discussion is not about "why you should or should not use package manager" but rather "if you use one, which, and why do you use that one?" Thanks.