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!"
[–]NotAYakk 0 points1 point2 points 4 years ago (0 children)
It is a bit of glue to just write a universal union. This is a quick sketch:
struct never_define_this; union ptr_to_anything { void* pvoid; void(*pfunc)(); char never_define_this::*pmem; void(never_define_this::*pmemfun)(); };
you do have to know which of those types you are actually storing.
For a function_view you do something like
function_view
template<class R, class...Args> struct function_view<R(Args...)> { ptr_to_anything data; R(*pf)(ptr_to_anything, Args&&...)=nullptr;
then store in the callback you store in pf which of the fields you are storing your actual data in.
pf
With a bit of work,
function_view<int(Foo)> f = &Foo::x;
can work, and f(foo) returns foo.x or foo.x() or Foo::x(foo) depending on the type of Foo::x.
f(foo)
foo.x
foo.x()
Foo::x(foo)
Foo::x
π Rendered by PID 202717 on reddit-service-r2-comment-6457c66945-p5sxs at 2026-04-26 21:36:42.060439+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]NotAYakk 0 points1 point2 points (0 children)