ali*_*glu 10 c++ xcode llvm clang c++11
#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;
}
Run Code Online (Sandbox Code Playgroud)
当我尝试在Xcode 5上编译时,我得到了
Use of undeclared identifier 'shared_from_this'
Run Code Online (Sandbox Code Playgroud)
我测试了它并在Visual Studio 2010上工作.
How*_*ant 16
return this->shared_from_this();
^^^^^^
Run Code Online (Sandbox Code Playgroud)
VC++ 2010没有完全正确地实现模板化基类的查找规则.铿锵行为是正确的.上述修复程序将使其适用于您的两个平台.