When I\'m writing a function in a template class how can I find out what my T is?
e.g.
template
ostream& operator << (os
C++ templates don't work this way. The general idea of templates is express somethings which is common for a lot of different types. And in your case you should use template specialization.
template ostream& operator<< (ostream& out, const vector& v)
{
// your general code for all type
}
// specialized template
template<> ostream& operator<< (ostream& out, const vector& vec)
{
// your specific to iny type code goes here
}
Then C++ compiler will call this function when you use int type and general implementation for any other type
std::vector f(5, 5);
std::cout << f;