c++ - how to query if(T==int) with template class -
when i'm writing function in template class how can find out t is?
e.g.
template <typename t> ostream& operator << (ostream &out,vector<t>& vec) { if (typename t == int) }
how can write above if statement works?
something this:
template< class t > struct typeisint { static const bool value = false; }; template<> struct typeisint< int > { static const bool value = true; }; template <typename t> ostream& operator << (ostream &out,vector<t>& vec) { if (typeisint< t >::value) // ... }
Comments
Post a Comment