function不是std的成员
请问各位前辈 :
“function” : 不是“std”的成员,如何解决? 网上的一段代码,我拷过来学习下,我是vs2003环境
using namespace std;
#include "TestInfo.h"
#include <vector>
#include <sstream>
#include <iostream>
#include <functional>
#include <typeinfo>
#include <algorithm>
/**
* @brief 测试基础类。
*
*/
class TestBaseEX
{
public:
typedef std::function<bool(TestInfo&)> TestFun;
/**
* @brief 执行测试。
* @param[in] testShow 测试结果展示函数
*
*/
void OnTest(std::function<void(TestInfo&)> testShow)
{
for (auto it = m_Tests.begin(); it != m_Tests.end();
++it)
{
TestInfo info;
try
{
bool result = (*it)(info);
if (info.isWantException)
{
info.isOK = false;
}
else
{
info.isOK = result;
}
}
catch (...)
{
info.exception = "有异常";
if (info.isWantException)
{
info.isOK = true;
}
}
testShow(info);
}
}
public:
std::vector<TestFun> m_Tests;
};