title: Using template instead of switch
body: <p>I want to perform a set of tests in my code that are similar but change only depending on a parameter.</p>
  
  <p>I could write this using a switch statement:</p>
  
  <pre><code>bool doTest(EnumSensorFamily family, const StructSensorProposal&amp; proposed)
  {
    switch (family)
    {
    case FAM1:
      return (ExpectedFam1 == proposed.Fam1SensorId);
      break;
    case FAM2:
      return (ExpectedFam2 == proposed.Fam2SensorId);
      break;
    case FAM3:
      return (ExpectedFam3 == proposed.Fam3SensorId);
      break;
    default:
      ERROR ("Unexpected family");
      return false;
    }
  }
  </code></pre>
  
  <p>I was thinking of doing this with template specialisations</p>
  
  <pre><code>template &lt;EnumSensorFamily family&gt;
  bool doTest(const StructSensorProposal&amp; proposed);
  
  template&lt;&gt;
  bool doTest&lt;FAM1&gt; (const StructSensorProposal&amp; proposed)
  {
    return (ExpectedFam1 == proposed.Fam1SensorId);
  }
  
  template&lt;&gt;
  bool doTest&lt;FAM2&gt; (const StructSensorProposal&amp; proposed)
  {
    return (ExpectedFam2 == proposed.Fam2SensorId);
  }
  
  template&lt;&gt;
  bool doTest&lt;FAM3&gt; (const StructSensorProposal&amp; proposed)
  {
    return (ExpectedFam3 == proposed.Fam3SensorId);
  }
  </code></pre>
  
  <p>Is there any benefit of doing this apart from avoiding a switch statement containing near identical cases?</p>
  
  <p>Ideally I would like to be able to write single method to reduce the maintenance overhead.</p>
  
  <p>thanks</p>