title: auto with ternary operator and templates
body: <p>I have a template class</p>
  
  <pre><code>template &lt;typename T&gt;
  class foo;
  </code></pre>
  
  <p>There are 2 valid values for T, corresponding to:</p>
  
  <pre><code>using fooT1 = class foo&lt;T1&gt;;
  using fooT2 = class foo&lt;T2&gt;;
  </code></pre>
  
  <p>I wanted to write code which looks like:</p>
  
  <pre><code>const auto* fooPtr = useFooT1 ? getFooT1Ptr() : getFooT2Ptr();
  </code></pre>
  
  <p>because the code using <code>fooPtr</code> in this function doesn't depend on whether fooPtr is of type <code>fooT1</code> or <code>fooT2</code></p>
  
  <p>However, I get the following compiler error:</p>
  
  <pre><code>error: conditional expression between distinct pointer types ...
  </code></pre>
  
  <p>I understand that as per the C++ standard, there should be a common type that both can be casted to, so this approach may not work.</p>
  
  <p>What's a good way to achieve this functionality without replicating a lot of code?</p>