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

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -