#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上工作.