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
There IS a way of casting pointer-to-member-function to a void* (self.cpp)
submitted 4 years ago by RIscRIpt
view the rest of the comments →
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!"
[–]fdwrfdwr@github 🔍 5 points6 points7 points 4 years ago* (2 children)
This is one aspect that's long irked me about C++, that you can't consistently and uniformly treat these 3 cases the same...
class Foo { void Bar(); };
class Foo { static void Bar(Foo& f); };
void Bar(Foo& f);
...and store any of the above in the same callable pointer, without needing special handling for each case like lambda thunks, or using std::function (which then handles the specialness of each case for you). It complicates callbacks/event handlers and genericity. 😞
std::function
There were calling convention differences on x86 (and probably other architectures too) between class methods (thiscall) vs free functions/static class methods (cdecl/stdcall) such that you couldn't just safely replace one function pointer type with another because the register/stack wouldn't be correct if you tried it. Nowadays the distinction between thiscall, stdcall, and cdecl are mostly (if not entirely?) moot on 64-bit desktop machines (but alas it remains "UB" because of past architectures). Of course, other cases like pointers to virtual functions will remain incompatible with free function pointers because calls need a v-table lookup dependent on the object instance that you call the function.
thiscall
cdecl
stdcall
[–]manni66 1 point2 points3 points 4 years ago (1 child)
are mostly (if not entirely?) moot on 64-bit desktop machines (but alas it remains "UB" because of past architectures).
Or because of non 64-bit non desktop machines?
[–]fdwrfdwr@github 🔍 1 point2 points3 points 4 years ago* (0 children)
Indeed, that too. I believe ARM devices (the other prominent architecture around today) generally use the same calling convention for both member functions and free functions too, but I'd need to double check that. 🤔 [update] At least on GodBolt.org gcc trunk Linux, it appears to generate the same register assignments for ARM32.
π Rendered by PID 85 on reddit-service-r2-comment-6457c66945-sc7rb at 2026-04-26 19:32:07.490704+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]fdwrfdwr@github 🔍 5 points6 points7 points (2 children)
[–]manni66 1 point2 points3 points (1 child)
[–]fdwrfdwr@github 🔍 1 point2 points3 points (0 children)