std::list containing std::function
问题 What I'm trying to achieve is std::list that contains std::functions . I'm trying to implement a callback system where functions can be added to the list and then the list can be looped through and each function called. What I have in class A is: std::list<std::function<void( bool )>> m_callbacks_forward; bool registerForward( std::function<void(bool)> f ) { m_callbacks_forward.push_back ( f ); return true; }; void GameControllerHub::invokeForward( bool state ) { for( std::list<std::function