Menu
  • HOME
  • TAGS

Match type of inherited member functions

c++,c++11,match,sfinae,member-pointers

Here's a simple class that passes your tests (and doesn't require a dozen of specializations :) ). It also works when foo is overloaded. The signature that you wish to check can also be a template parameter (that's a good thing, right?). #include <type_traits> template <typename T> struct is_foo {...

Assign the designated function to the function member pointer?

c++,struct,function-pointers,member-pointers

You don't dereference a pointer when assigning it to point to an object. g_ptr_table->hello = &hello; // note: the & is optional g_ptr_table->hello(); // dereferencing the function pointer is also optional ...

Call function through pointer to class member

c++,member-pointers

This works in ideone: void bar_function(foo bar::*p_foo) { (this->*p_foo).foo_function(); } It's all about having the right level of indirection. Since p_foo is a pointer to member, we need to dereference it before attempting to access it from this. At this point, you have the actual foo_member object, not a pointer...

Member Variable Pointer

c++,c++11,wrapper,member-pointers,mem-fun

N.B. Nothing in your question is from the STL (which is a library from the 1990s), std::function and std::mem_fn are part of the C++ Standard Library, which is not the same thing. std::mem_fn supports member functions and member variables, so you can just do this to access the member variable...