如何开始使用Visual Studio2010的tr1特性?对于更具体的情况,我需要std::tr1::函数。我尝试包含报告为丢失的#include <tr1/functional>,而#include <functional>包含正常,但当我设置以下内容时:
std::tr1::function<void(void)> callback;我得到了:
1>d:\marmalade\projects\core\src\button.h(21): error C3083: 'tr1': the symbol to the left of a '::' must be a type
1>d:\marmalade\projects\core\src\button.h(21): error C2039: 'function' : is not a member of '_STL'
1>d:\marmalade\projects\core\src\button.h(21): error C2143: syntax error : missing ';' before '<'
1>d:\marmalade\projects\core\src\button.h(21): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\marmalade\projects\core\src\button.h(21): error C2238: unexpected token(s) preceding ';'如果我使用boost,它工作得很好,但对于这个项目,由于使用了特定的框架,我需要Visual Studio tr1版本。
正如建议的那样,跳过tr1仍然会返回相同的结果:
std::function<void(void)> callback;
1>d:\marmalade\projects\core\src\button.h(20): error C2039: 'function' : is not a member of '_STL'
1>d:\marmalade\projects\core\src\button.h(20): error C2143: syntax error : missing ';' before '<'
1>d:\marmalade\projects\core\src\button.h(20): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\marmalade\projects\core\src\button.h(20): error C2238: unexpected token(s) preceding ';'发布于 2012-05-02 03:57:07
基于你的评论和this page,我认为Marmalade附带了它自己的STL实现,这似乎已经过时了。This page验证他们使用的STLPort版本不支持2005年发布的TR1,更不用说更新的版本了。您可以选择:
1)自己复制/编写
2)没有
3) Download a newer version of STLPort。它似乎在过去两年中没有更新过,所以没有C++11,但他们确实提到了functional,但不清楚它是在std还是std::tr1名称空间中。但是,这可能不适用于Marmalade,因此请进行备份并小心。
发布于 2012-05-02 03:18:49
Visual Studio2010附带了默认启用的C++11 (或者至少是实现的)。您需要使用std::function<void(void)>。
以获取完整的表see here。
顺便说一句:你现在不应该使用TR1的任何东西。它已被集成到新标准中。
https://stackoverflow.com/questions/10402924
复制相似问题