Here is a minimal example that follows the basic idea of that code:
#include <map>
#include <functional>
class State
{
public:
virtual ~State ();
// Current state
static State * current();
static void current(const State *state);
// Events
virtual void draw () = 0;
virtual void receive (int c) = 0;
};
enum ChapterEnum {
CHAPTER_SELECTION
};
class MainMenu : public State
{
MainMenu::MainMenu ()
{
// m_main_menu
menuItems.insert(std::make_pair('c', []{}));
menuItems.insert(std::make_pair('n', []{substate(CHAPTER_SELECTION);}));
menuItems.insert(std::make_pair('q', []{State::current(nullptr);}));
}
static State *substate(ChapterEnum);
std::map<char, std::function<void ()>> menuItems;
};
int main() {
}
Hint: minimal examples are something we can actually compile. It should not include references to things that you haven't posted.
This produces the following warning:
Quote
1>c:\programming\c++0x\help\help\help.cpp(29): warning C4573: the usage of 'State::current' requires the compiler to capture 'this' but the current default capture mode does not allow it
Googling the error code gave me
this and
also this, which both claim this is a compiler bug (as it appears to be).