#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;
}
Kiedy próbuję skompilować ten na Xcode 5 i dostaćenable_shared_from_this nie działa na Xcode 5
Use of undeclared identifier 'shared_from_this'
Przetestowałem go i jego pracę w Visual Studio 2010.
Zapomniałeś zakwalifikować go za pomocą 'std ::' tak jak w przypadku 'std :: shared_from_this()'. –
Nie ma tutaj std namespace wymagane tylko do rozszerzenia z enable_shared_from_this i typu return funkcji getMe i są już wpisane. –
Plus shared_from_this jest funkcją członkowską w klasie enable_shared_from_this. Czy na pewno czytasz pytanie? –