title: C++ template - using "std::is_same_v" instead of specializing and avoid compilation error?
body: <p>I'm new to templates and I'm trying to use them in order to avoid duplicating functions that are very much alike.</p>
  <p>In the example below, I made a simple and small working example showing my issue.</p>
  <p>In particular, I have two <code>struct</code> (&quot;solo&quot; and &quot;duo&quot;). Those struct's have a common member (a) and one of them has a specific member (b).</p>
  <p>Then I have a template function that can take either struct and print the member a... and I wanted it to be able to print member b only if the struct type is &quot;duo&quot;.</p>
  <p>The way I did (using <code>std::is_same_v</code>) it doesn't compile. I read that one can use specialization to do so, however I was wondering if there is not a more elegant way? Because then I have the feeling to loose the advantage of templates... but probably I don't get the power of templates yet and how/for what to use them.</p>
  <p>Thank you very much for your help!</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;type_traits&gt;
  
  struct solo{
    int a;     
  };
  
  struct duo : solo{
      int b;
  };
  
  template&lt;class T&gt;
  void function(T test){
   std::cout&lt;&lt; std::to_string(test.a);
   if(std::is_same&lt;T, duo&gt;::value) std::cout&lt;&lt; std::to_string(test.b);
  }
  
  int main()
  {
    solo testS;
    testS.a = 1;
  
    function(testS);
  }
  </code></pre>