-3

So, I have no reason to use std::function for this statement. Just from what I read the following statement can be written using std::function.

How should this statement look like? Written with std::function

template <class T>
class CFooTemplate
{
public:
    typedef void (T::*FOO_STATE)(void);

Explain a little, the logic behind writing.

merry
  • 3
  • 3

1 Answers1

0

I'm not entirely sure what you mean but I'll give it a stab.

How should this statement look like? Written with std::function

If I understand correctly, you mean this line: typedef void (T::*FOO_STATE)(void);

In this case, you would write typedef std::function<void()> FOO_STATE;

This is because you're using a pointer to a (member) function. The signature of the function itself is void(), which in C++ is equivalent to void(void) as you used.

std::function takes the raw signature (e.g. void() or void(void)) and creates a polymorphic wrapper for any function of that general signature, be it a normal function, member function, or function-like object.

Cruz Jean
  • 2,761
  • 12
  • 16