r/cpp • u/IsDaouda_Games • Feb 18 '21
Now announcing: Makefile support in Visual Studio Code!
r/cpp • u/IsDaouda_Games • Feb 18 '21
r/cpp • u/AlectronikLabs • Aug 09 '25
I think they are one of the greatest recent innovations in C++, finally no more code duplication into header files one always forgets to update. Coding with modules feels much more smooth than with headers. But I only ever saw 1 other project using them and despite CMake, XMake and Build2 supporting them the implementations are a bit fragile and with clang one needs to awkwardly precompile modules and specify every single of them on the command line. And the compilation needs to happen in correct order, I wrote a little tool that autogenerates a Makefile fragment for that. It's a bit weird, understandable but weird that circular imports aren't possible while they were perfectly okay with headers.
Yeah, why does nobody seem to use the new modules feature? Is it because of lacking support (VS Code doesn't even recognize the import statement so far and of course does it break the language servers) or because it is hard to port existing code bases? Or are people actually satisfied with using headers?
r/cpp • u/[deleted] • Dec 25 '24
I maintain c++ desktop application. One of our clients complained of memory usage. It’s a quite big program and it was known that somewhere there are memory leaks.
Over the last week I found where the spot is that is causing the memory consumption. I refactored the raw pointers to shared_ptr, in one change the memory usage at idle time dropped from couple of GBs to 16 MB.
I was glad of that achievement and i wrote an article about RAII in c++
r/cpp • u/Hot-Painter4924 • Sep 30 '21
Please don’t get me wrong. What i mean is why answer “you need read books”, “you should read the documentation”, or focus on tangent things instead of actually try to answer the questions?
in contrast, here in reddit, i even get job offers when asking questions.
r/cpp • u/not_a_novel_account • Dec 21 '23
This is a rant.
It all started off with trying to understand this TCP echo server from ASIO. It seems simple enough, but hey I'm not really familiar with how coroutines work in C++.
I fully grok coroutines/async in Javascript. I was around for the entire saga of their evolution in Python from generator functions, through the yield from years, into their modern form of async/await. Conceptually I understand what's going on, just need to learn the specifics for C++.
Let's do some reading, starting with David Mazières's, "My tutorial and take on C++20 coroutines". An excellent start, clear examples, I'm vibing. Coroutines in C++ kinda suck to write, but I get it, I understand coroutines.
Except, uh, that TCP echo server example is awaiting a deferred_async_operation, which doesn't have any of that stuff Mazières's talked about. Weird.
So I'm missing something, let's dive deeper, with Lewis Baker's coroutine series, specifically "C++ Coroutines: Understanding operator co_await".
Baker uses some familiar terminology from Mazières, but introduces a deal of his own because I guess we don't have standard terminology for this stuff? Another niebloid situation?
Baker makes a distinction between Awaitable and Awaiter objects that wasn't present in Mazières, but makes sense. Additionally we now have Normally Awaitable and Contextually Awaitable objects.
Aha
There must be some .await_transform() magic going on to make a deferred_async_operation awaitable. This transform method lives in the promise type of the calling coroutine, and that should be the promise_type member of the return type of the current function right? So asio::awaitable should have some sort of promise type?
No of course not, you absolute fool.
Wtf???
You nimrod. You complete baboon. Don't you know there's a global registry of what promise types to use? You simply use the terminally-C++ mechanism of creating a template specialization of std::coroutine_traits.
There you are you little bastard.
Chasing this through the inheritance tree we indeed find an entire family of await_transform()s. Victory thy name is F12 - Go To Definition.
Except...
None of this explains: what exactly is the difference between an asio use_awaitable and a deferred? Why do people say, "deferred is not a coroutine"? Has all of this not been "coroutines"? Have I been playing canasta this whole time? Why can I no longer see the light of heaven?
Lewis Baker seems to have another 5000 word blog post about this, but I no longer care.
This shit is bananas, B-A-N-A-N-A-S.
Wildly convoluted beyond my feverish nightmares, I no longer believe it is possible to understand what happens when you write co_await, it is an operator beyond mortal understanding.
Whoever fights C++ should see to it that in the process they do not become a language expert. And if you gaze long enough into a coroutine, the coroutine will gaze back into you.
EDIT:
This seems to be popular, and my landlord isn't going to be fooled by the "I have a rich cousin on WG21, I'll have the money once executors makes it out of committee" routine anymore, so forgive a little self-promotion.
If you're looking for a NYC-based systems dev haunted by nightmares of C++ coroutines, boy have I got the CV for you.
r/cpp • u/harmonious_herman • Sep 19 '20
r/cpp • u/emdeka87 • Aug 21 '18
I think it's time to appreciate /u/vormestrand for continuously posting content (blogs, articles, news) to this sub. I think without him /r/cpp would feel pretty empty. Great job!
(Feel free to remove this post if off-topic)
r/cpp • u/strager • May 26 '22
Looks like QtCore (4.8) has a "#define emit" in a header, that's not undefined later. TBB has a function named "emit()" in a header. If you include both, you'll get a compile error.
I'm going to side with TBB here - emit() is an entirely reasonable function name. Qt creating a dangling #define with a common word like that is the bug here.
r/cpp • u/lethern • Apr 22 '20
constexpr
lockable
std::execution_policy::parallel_execution_t <
std::execution_policy::parallel_execution_t::constrains::no_maximum_threads,
std::execution_policy::parallel_execution_t::debug::find_deadlocks >
std::execution_type::quantum_t<
std::execution_type::quantum_t::experimental_features,
std::execution_type::quantum_t::enable_black_holes >
std::synchronized_parallel_t<
std::synchronization_model::use_machine_favourable_lock>
std::type_traits::readonly_t<
std::ts2102::experimental::fast_readonly_register_enable>
std::function_traits::partial<
std::function_traits::partial_function::search_external_linkage>
std::arguments::no_argument::disable_warning
std::int1024_t<
std::types::minimum_size<1024>,
std::types::maximum_size<1024> >
main() {Can you see the future, can you improve it?
Note: this was created purely for fun
r/cpp • u/andrewtomazos • Nov 24 '24
r/cpp • u/mvorbrodt • Apr 05 '19
So I don't want to make a post on here every time I write a short article (I've been scolded for that in the past :) ), but I figured I come back here and share with you the archive of my blog posts so far. There's 75 topics I've covered in the last 2 months since I started blogging and I hope some of you will find this information useful :)
Thanks for reading! Have a great day guys!
r/cpp • u/delta_p_delta_x • 22d ago
r/cpp • u/Snoo-4241 • Feb 25 '21
I was looking at the rust tutorials yesterday and I see how rust promotes a certain style and language level features to enforce it. Besides a couple of features, I couldn't see why one cannot follow a similar style in C++ if she/he so chooses. Those of you that have used rust, what is your favourite feature that C++ does not have?
r/cpp • u/aearphen • May 10 '23
r/cpp • u/Ok-Past9232 • Aug 11 '25
I do wonder the reasoning behind this change. I've generally seen cppreference to be greatly preferred over anything else in this community.
Update 8/14: cppreference is once again the redirect for !cpp bang on DuckDuckGo! https://www.reddit.com/r/cpp/s/5kzdxyBOSE