title: C++: Cannot initialize a parameter of type 'char*' with an lvalue of type 'double' in a template function using type conditional
body: <p>I want to write a template function to copy data from one array to another array. I only want to handle <code>int</code>, <code>double</code> and <code>char*</code> (string) arrays in my program.</p>
  
  <pre><code>template&lt;typename T&gt;
  void copy_key(T *destination, int destination_index, T *source, int source_index){
      if (typeid(T) == typeid(int) or typeid(T) == typeid(double)){
          destination[destination_index] = source[source_index];
      } else {
          // char* case
          strcpy(destination[destination_index], source[source_index]);
      }
  }
  </code></pre>
  
  <p>If I call <code>copy_key()</code> as below, I will get error :  Cannot initialize a parameter of type 'char*' with an lvalue of type 'double'.</p>
  
  <pre><code>int main(int argc, const char * argv[]) {
      double from_array[3] = {1.0,2.0,3.0};
      double to_array[3];
      copy_key(to_array, 0, from_array, 2);
      std::cout &lt;&lt; to_array[0] &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>I thought if <code>T</code> was <code>double</code>, the else block would not be entered. My question is how to correctly use condition on the template type in my example?</p>