First of all, I'm using code blocks on windows with the latest mingw release. I am using the sfml library to start a game, but unfortunately I came across this problem. I need to use std::function for my state manager, but it keeps showing the same error: 'std::function' has not been declared. I did #include<functional>
and used the linker option -std=c++0x, but still no luck. The only thing that doesn't compile is this one header:
#ifndef STATEMANAGER_HPP_INCLUDED
#define STATEMANAGER_HPP_INCLUDED
#include <vector>
#include "State.hpp"
#include <functional>
#include <SFML/Graphics.hpp>
class StateManager {
public:
StateManager();
~StateManager();
void registerState(int id, std::function< State*() > createFunc);
void setState(int id);
void update();
void draw(sf::RenderTarget &target);
private:
std::vector< std::function< State*() > > mStates;
State *mCurrentState;
};
#endif // STATEMANAGER_HPP_INCLUDED
I have no idea what the problem is. Anyone know whats wrong here?
I figured it out. Some credit to Piotr S. I tried std::tr1::function but that didn't work on its own, so i just included tr1/functional and it worked. Thanks!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With