Mingw'std :: function'尚未声明?

use*_*725 5 c++ std sfml c++11

首先,我在具有最新mingw版本的Windows上使用代码块。我正在使用sfml库开始游戏,但不幸的是我遇到了这个问题。我需要为状态管理器使用std :: function,但它始终显示相同的错误:尚未声明'std :: function'。我确实#include<functional>使用了链接器选项-std = c ++ 0x,但还是没有运气。唯一无法编译的是此标头:

#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
Run Code Online (Sandbox Code Playgroud)

我不知道是什么问题。有人知道这里有什么问题吗?

use*_*725 5

我想到了。Piotr S 的一些功劳。我尝试过 std::tr1::function 但它本身不起作用,所以我只包含了 tr1/functional 并且它起作用了。谢谢!