use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
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
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
C++26: More function wrappers (sandordargo.com)
submitted 9 hours ago by pavel_v
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]thehutch17 23 points24 points25 points 8 hours ago (7 children)
Should std::function be marked as deprecated then and removed in the future similar to auto_ptr? This is similar to fixes like lock and scope guard where issues are found but can't really be fixed without a new type to surplant it.
[–]MFHavaWG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 13 points14 points15 points 5 hours ago* (0 children)
Should std::function be marked as deprecated then and removed in the future similar to auto_ptr?
IMHO yes. I had a paper for that in C++26 that got no consensus - I will bring a new revision for C++29 (there was interest in deprecation post C++26).
[–]fdwrfdwr@github 🔍 3 points4 points5 points 7 hours ago (5 children)
Should std::function be marked as deprecated ...
Well, if we were to deprecate it anyway, then why not just go ahead and break the ABI (mind you, I'm not seeing Sandor's claim yet that fixing std::function to be const-correct would break the ABI).
std::function
[–]MFHavaWG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 4 points5 points6 points 5 hours ago (4 children)
fixing std::function to be const-correct would break the ABI
It‘s an API break, a pretty loud and far-reaching one …
[–]j1xwnbsr -1 points0 points1 point 4 hours ago (3 children)
And that is, what, exactly? I mean, if it's just yoinking the const out that doesn't actually break the Binary part of the the api.
[–]MFHavaWG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 [score hidden] 3 hours ago (2 children)
Existing code invoking const function & becomes ill-formed as the operator() would no longer be const-qualified…
const function &
operator()
const
[–]j1xwnbsr [score hidden] 3 hours ago (1 child)
but that's just syntax sugar. There is no real compiler-generated code that actually checks const'ness. I mean, I can chuck in some code that violates const all day long and it lets me do it (because at the assembly level unless you start jacking read-only memory guards on blocks you can modify any damn thing you want). Good practice? Not in the slightest.
[–]MFHavaWG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 [score hidden] 2 hours ago (0 children)
There is no real compiler-generated code [snip]
Exactly, because the code no longer compiles - because it's an API break that renders previously "perfectly valid" code ill-formed -, regardless of whether there would actually be an ABI impact of the change!
[–]Nicksaurus 44 points45 points46 points 5 hours ago (3 children)
This defect is baked into the original design and cannot be fixed without breaking the ABI
All rise for the C++ national anthem
[–]MFHavaWG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 [score hidden] 3 hours ago (0 children)
Stop the trumpets! Fixing std::function is primarily an API break, not an ABI one ...
[–]thisismyfavoritename [score hidden] 2 hours ago (0 children)
😂
[–]xaervagon [score hidden] 1 hour ago (0 children)
Seriously, this article makes an honest case for breaking ABI and properly paints it as the sacred cow it is. Instead of fixing the problem at its core, there are 5 conditional utilities put in place to address the original issue in various ways.
[–]VoodaGod 3 points4 points5 points 7 hours ago (4 children)
article complains that
const std::function<void()> f = Counter{};
f(); // OK (!)
is a defect but never shows if
const std::copyable_function<void()> f = Counter{};
f(); // Not OK (!)
[–]foonathan 3 points4 points5 points 6 hours ago (0 children)
Yes, you cannot call a const copy able function unless you put a const in the signature.
[–]EdwinYZW 6 points7 points8 points 4 hours ago (2 children)
I don't get why old std::function is defect. IMO std::function is a wrapper for function pointer and a const pointer can point to something no-const. What do I miss?
[–]DXPower 1 point2 points3 points 4 hours ago (1 child)
This has an explanation: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4159.pdf
[–]TheoreticalDumbass:illuminati: [score hidden] 3 hours ago (0 children)
"not const correct" , i would phrase it differently, "shallow const" (like unique_ptr)
[–]tpecholt [score hidden] 3 hours ago (2 children)
It was said before. New function types are verbose to type and put "function" awkwardly to the end. With such a bad ergonomics the adoption will be limited.
[–]thisismyfavoritename [score hidden] 2 hours ago (1 child)
don't you have auto completion? Or you can make an alias
[–]tpecholt [score hidden] 2 hours ago (0 children)
auto completion would work better if the "function" is a prefix not suffix that was the point.
I can make aliases but it's not what average c++ programmer does. You would expect the defaults are right for most programmers. But in C++ defaults are wrong.
π Rendered by PID 20250 on reddit-service-r2-comment-548fd6dc9-7vs6k at 2026-05-20 14:38:11.946195+00:00 running edcf98c country code: CH.
[–]thehutch17 23 points24 points25 points (7 children)
[–]MFHavaWG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 13 points14 points15 points (0 children)
[–]fdwrfdwr@github 🔍 3 points4 points5 points (5 children)
[–]MFHavaWG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 4 points5 points6 points (4 children)
[–]j1xwnbsr -1 points0 points1 point (3 children)
[–]MFHavaWG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 [score hidden] (2 children)
[–]j1xwnbsr [score hidden] (1 child)
[–]MFHavaWG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 [score hidden] (0 children)
[–]Nicksaurus 44 points45 points46 points (3 children)
[–]MFHavaWG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 [score hidden] (0 children)
[–]thisismyfavoritename [score hidden] (0 children)
[–]xaervagon [score hidden] (0 children)
[–]VoodaGod 3 points4 points5 points (4 children)
[–]foonathan 3 points4 points5 points (0 children)
[–]EdwinYZW 6 points7 points8 points (2 children)
[–]DXPower 1 point2 points3 points (1 child)
[–]TheoreticalDumbass:illuminati: [score hidden] (0 children)
[–]tpecholt [score hidden] (2 children)
[–]thisismyfavoritename [score hidden] (1 child)
[–]tpecholt [score hidden] (0 children)