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

Popular posts from this blog

PHP while loop dynamic rowspan -

timer - Java TimerTask cancel -

android - How to read a column value in parse.com without accessing an object or a pointer -