繁体   English   中英

如何在Visual Studio 2010中使用tr1(tr1 :: function)?

[英]How to use tr1 with Visual Studio 2010 (tr1::function)?

如何开始使用Visual Studio 2010的tr1功能? 对于更具体的情况,我需要std :: tr1 :: function。 我尝试将#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 ';'

根据您的评论,在这个页面上 ,我认为Marmalade附带了它自己的STL实现,它看起来已经过时了。 此页面验证他们使用的是STLPort版本,该版本不支持2005年推出的TR1,更不用说更新的版本了。 你的选择是:

1)自己复制/写这些
2)没有
3) 下载更新版本的STLPort 它似乎在过去两年中没有更新,所以没有C ++ 11,但它们确实提到了functional ,但是不清楚它是否在stdstd::tr1命名空间中。 但是,这可能不适用于Marmalade,因此请进行备份并小心。

Visual Studio 2010默认启用C ++ 11(或至少实现了什么)。 您需要使用std::function<void(void)>

有关完整的表格, 请参见此处

暂且不说:现在你不应该使用TR1中的任何东西。 它已被纳入新标准。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM