dimanche 30 août 2015

How can I create C++ functions which return each other?

I want to have a few functions in C++ where each function represents a screen in the program. The functions handle user interaction, and based on that will return a std::function to one of the other functions, with parameters bound via std::bind so that the return value can be called with no arguments. It is possible to get from any function to any other function by this process, without using recursion - the main function would be an infinite loop that just calls the returned function over and over.

But I'm stumped here - what should the definition of the return type be for these functions? They need to return std::function objects that take no parameters, but that's as far as I can get. std::function<what_goes_here ()>?

Aucun commentaire:

Enregistrer un commentaire