如何将 tr1 与 Visual Studio 2010 (tr1::function) 一起使用
How to use tr1 with Visual Studio 2010 (tr1::function)?
如何开始使用Visual Studio 2010的tr1功能?对于更具体的情况,我需要 std::tr1::函数。我尝试包括#include <tr1/functional>
哪些报告为丢失,而#include <functional>
包括很好,但是当我设置它时:
std::tr1::function<void(void)> callback;
我得到:
1>d:marmaladeprojectscoresrcbutton.h(21): error C3083: 'tr1': the symbol to the left of a '::' must be a type
1>d:marmaladeprojectscoresrcbutton.h(21): error C2039: 'function' : is not a member of '_STL'
1>d:marmaladeprojectscoresrcbutton.h(21): error C2143: syntax error : missing ';' before '<'
1>d:marmaladeprojectscoresrcbutton.h(21): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:marmaladeprojectscoresrcbutton.h(21): error C2238: unexpected token(s) preceding ';'
如果我使用 boost,它可以正常工作,但对于这个项目,由于使用特定的框架,我需要 Visual Studio tr1 版本。
正如建议的那样,跳过 tr1,仍然返回相同的结果:
std::function<void(void)> callback;
1>d:marmaladeprojectscoresrcbutton.h(20): error C2039: 'function' : is not a member of '_STL'
1>d:marmaladeprojectscoresrcbutton.h(20): error C2143: syntax error : missing ';' before '<'
1>d:marmaladeprojectscoresrcbutton.h(20): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:marmaladeprojectscoresrcbutton.h(20): error C2238: unexpected token(s) preceding ';'
根据您的评论,以及在此页面上,我认为 Marmalade 附带了它自己的 STL 实现,这似乎已经过时了。 此页面验证他们是否使用了STLPort版本,该版本不支持2005年推出的TR1,更不用说更新的版本了。 您的选择是:
1)自己
复制/编写2)不做
3) 下载较新版本的STLPort。 它似乎在过去两年中没有更新,所以没有 C++11,但他们确实提到有 functional
,但不清楚它是在 std
还是std::tr1
命名空间中。 但是,这可能不适用于果酱,因此请进行备份并小心。
>Visual Studio 2010附带默认启用C++11(或至少是实现的内容)。您需要使用std::function<void(void)>
.
有关完整表格,请参见此处。
顺便说一句:现在你不应该使用 TR1 中的任何内容。它已被整合到新标准中。
相关文章:
- "error: no matching function for call to"构造函数错误
- 调用专用模板时出错"no matching function for call to [...]"
- 库函数需要一个 std::function<void(void)>,如何传入类函数?
- Confusion: decltype vs std::function
- 为什么 std::function 可以作为 std::not2 的参数?
- 'max'匹配'std::function<const int &(const int &, const int &)>'无过载
- 传递给std::function template的template参数究竟代表什么
- 将带有unique_ptr的可变 lambda 传递给 const&std::function
- 绑定派生类方法C++从实例范围之外的分隔 std::function 变量调用
- "no matching function for call to 'Vector::Vector'"错误
- 如何在向量中删除 std::function<void()>?
- 不断"Attempting to reference a deleted function"
- 将函数包装器转换为 std::function
- 类型擦除的std::function与虚拟函数调用的开销
- C++ std::function 对于类 exept 的所有实例都是空的(只有 Visual2019 编译器问题)
- 如果模板没有可变参数,则 Lambda 被推导出为 std::function
- 我在 ifstream input_file(文件名)行中收到错误"no matching function to call";
- 模板规范获取'Ambiguous call to overloaded function'
- boost::function 和 std::tr1::function 之间是否有重要的区别需要了解
- 如何将 tr1 与 Visual Studio 2010 (tr1::function) 一起使用