title: Comparing A Data Type in an If Statement
body: <p>Is there a way to test a parameter's data type in an if statement? Here is an example of source code: it will not compile but it used to present my intentions.</p>
  
  <pre><code>typedef char cInt[sizeof(int)];
  typedef char cFloat[sizeof(float)];
  typedef char cDouble[sizeof(double)];
  
  template&lt;typename T&gt;
  char* convertToCharStr( const T&amp; t ) {
      if ( t == int ) {
          cInt c = t;
          return c;
       }
       if ( t == float ) {
          cFloat c = t;
          return c;
       }
       if ( t == double ) {
          cDouble c = t;
          return c;
       }
       return nullptr;
  }
  </code></pre>
  
  <p>As you can see, I am trying to create a template function that can take any default data types such as an int, unsigned int, float, double and depending 
  on the data type it will create the appropriate char[] variable on the stack according to the data type passed in and store the data into the char[] and return the pointer out of the function.</p>
  
  <p>I will leave this above the way it is, but as a note the character arrays should of been unsigned char.  </p>