Define TUniqueFunction for class member function

Hi

I can get TUniqueFunction to work for global function
but not a class member function

Global Compiles
TUniqueFunction<int()> mvo_WorkerTask = TestFunc;

Class Member Does Not Compile
TUniqueFunction<void()> mvo_WorkerTask3 = &ABounceMeshActor::mfs_WorkerFunc

Any tips on how to use class member function for this
Cheers

Free functions and static member functions have different signature than non-static member function, because of hidden this parameter.
So



void freeFunction(void) { }   // signature is void(*)();
struct Foo
{
  void memberFunction() {} // signature is void(Foo::*)();
  static void staticFunction() {} // signature is void(*)();
};


You can use lambda:



void f()
{
  auto myFoo = new Foo;
  TUniqueFunction<void()> callback = [myFoo]{ myFoo->memberFunction(); });
}


Note that TUniqueFunction is not copyable, so by making it a class member - the whole class becomes non-copyable.

Hi

Thanks very much for the feedback, could you please show the actual syntax declaration for the functions, just like you did for lambda, I dont use lamda.

Thanks again.