title: how to do an if else depending type of type in c++ template?
body: <pre><code>// template specialization
  #include &lt;iostream&gt;
  using namespace std;
  
  // class template:
  template &lt;class T&gt;
  class mycontainer {
      T element;
    public:
      mycontainer (T arg) {element=arg;}
      T increase () {
  
      //if(T.type==int)//how to do this or something similar?
      //do this if an int
      return ++element;
  
      //if(T.type==char)
       //if ((element&gt;='a')&amp;&amp;(element&lt;='z'))
        //element+='A'-'a';
        //return element;
  
      }
  };
  </code></pre>
  
  <p>I know how to write a template specialization and do a separate whole class def just for the char type.</p>
  
  <p>But what if I wanted to handle everything in just one block of code?</p>
  
  <p>How can I check if T is an int or a char?</p>