Enable_shared_from_this在xcode 5上不起作用
enable_shared_from_this not working on xcode 5
#include <iostream>
#include <memory>
template<typename T>
class Test: public std::enable_shared_from_this< Test<T> >
{
public:
std::shared_ptr< Test<T> > getMe()
{
return shared_from_this();
};
};
int main(int argc, const char * argv[])
{
Test<int> aTest;
return 0;
}
当我尝试在Xcode 5上编译这个时,我得到
Use of undeclared identifier 'shared_from_this'
我测试了它,它在Visual Studio 2010上运行。
return this->shared_from_this();
^^^^^^
vc++ 2010没有完全正确地实现模板基类的查找规则。叮当的行为是正确的。上面的修复将使它在您的两个平台上工作。
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- C++为什么尽管我调用了void函数,它却不起作用
- 为什么在保护模式下继承升级不起作用
- 循环在计数器中不起作用
- 在其他文件中创建类时在 c++ 项目中不起作用
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 为什么二进制搜索在我的测试中不起作用
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 为什么 const std::p air<K,V>& 在 std::map 上基于范围的 for 循环不起作用?
- 包括在 <sstream> Xcode 9.2 中不起作用
- 找不到WCHAR.H文件-Xcode 9.0中断QT创建者 - 旧修复程序不起作用
- XCode更新后,标头文件在CLION中不起作用
- Xcode 5 带有 %s 格式说明符的 LLVM printf 在调试控制台中不起作用
- Xcode 5 c++ fstream(ifstream 和 ofstream)不起作用
- std::wofstream::open 在 MAC/Xcode 上不起作用
- Xcode 代码感知不起作用(找不到符号)
- 在模板类中声明模板成员变量在 Xcode 中不起作用
- Enable_shared_from_this在xcode 5上不起作用