Mingw 'std::function' has not been declared?
10,073
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!
Author by
user3452725
Updated on June 04, 2022Comments
-
user3452725 almost 2 years
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?