The following function
#include <memory>
template<typename T>
std::shared_ptr<typename T> Tail(const std::shared_ptr<typename T>& cont, size_t n)
{
const auto size(std::min<size_t>(n, cont->size()));
return std::shared_ptr<typename T>(new T(cont->end() - size, cont->end()));
}
Produces the following error on gcc 4.7.2.
g++ test.cpp -std=c++0x
test.cpp:4:27: error: template argument 1 is invalid
test.cpp:4:66: error: template argument 1 is invalid
test.cpp: In function ‘int Tail(const int&, size_t)’:
test.cpp:6:42: error: base operand of ‘->’ is not a pointer
test.cpp:7:35: error: template argument 1 is invalid
test.cpp:7:47: error: base operand of ‘->’ is not a pointer
test.cpp:7:67: error: base operand of ‘->’ is not a pointer
I understand that cont does not 'look' like a pointer, but this compiles fine on VS2012. How can I write the function for gcc?