Java has a ::-operator that allows you to automagically create the equivalent of a std::function calling a non-static member function. For an example, see below
// One file
public class Test
{
public void test()
{
// Do stuff
}
}
// Another file
public class Main
{
public static void main(String... args)
{
Test testObject = new Test();
// The Java-equivalent of a std::function<void()>
// is being created by the expression below.
Runnable runnable = testObject::test;
}
}
Now, my question is: Is there also an equivalent operator of some sorts for this behavior in C++? Sure, I know that you can just use the assign operator and put the name of the target method on the right side, but this does sadly not work for non-static member functions. Is there an operator that I can use to make it work for non-static member functions as well?