title: Type based on template argument value
body: <p>I currently have a template function something like this:</p>
  
  <pre><code>enum class MyEnum { ENUM_1, ENUM_2, ENUM_3 };
  
  template&lt;MyEnum e, typename T&gt;
  void func( int i )
  {
      std::vector&lt;T&gt; someData = ......;
      T someValue;
  
      switch( e )
      {
          case ENUM_1:
              someValue += func1( someData );
              break;
          case ENUM_2:
              someValue += func2( someData );
              break;
          case ENUM_3:
              someValue += func3( someData );
              break;
      }
  }
  </code></pre>
  
  <p>The type <code>T</code> is dependent on the value of <code>e</code>. I'd like to write this code like</p>
  
  <pre><code>template&lt;MyEnum e&gt;
  void func( int i )
  {
      if( e = MyEnum:ENUM_1 ) T = char;
      else T = float;
  
      std::vector&lt;T&gt; someData = ......;
      T someValue;
  
      switch( e )
      {
          case ENUM_1:
              someValue += func1( someData, ..... );
              break;
          case ENUM_2:
              someValue += func2( someData, ..... );
              break;
          case ENUM_3:
              someValue += func3( someData, ..... );
              break;
      }
  }
  </code></pre>
  
  <p>I can see how to make a type dependent on another type, e.g.</p>
  
  <pre><code>typedef std::conditional&lt;std::is_same&lt;T1, float&gt;::value, char, float&gt;::type T;
  </code></pre>
  
  <p>but can't figure out how to extend this to cope with enum values. Is it possible to do what I want to? If so, how?</p>
  
  <p>Note: <code>func1</code>, <code>func2</code> and <code>func3</code> are fixed and beyond my control.</p>
  
  <p>Thanks!</p>