title: How to return a type from C++ functions?
body: <p>I'm reading <em>C++ Templates: The Complete Guide, 2th Edition</em>, And i see this code:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>template&lt;typename T1, typename T2&gt;
  std::common_type_t&lt;T1, T2&gt; max (T1 a, T2 b)
  {
      return b &lt; a ? a : b;
  }
  </code></pre>
  
  <p>According to what I've read from page 12, I want to ask how function figures the type it wants to return? In the above example, how <code>max</code> function figures the type it wants to return, choosing between T1 and T2?</p>
  
  <p>I looked in : <code>./gcc/libstdc++-v3/include/std/type_traits</code><em>:2115</em> but could not figure out what happened.</p>
  
  <p><strong>WHAT I WANT TO DO:</strong><br>
  I have a lot of <code>typedef</code>ed function pointer like this:</p>
  
  <pre class="lang-c prettyprint-override"><code>typedef void (*voidVoid)();
  typedef void (*voidInt)(int);
  typedef void (*voidDouble)(double);
  ...
  </code></pre>
  
  <p>And i want to make a function like:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>Type getFunctionPointer(const std::string&amp; name);
  </code></pre>
  
  <p>Which take name of function-pointer and return corresponding function-pointer. Before I find <code>template</code>s I thought it's not possible. But I think, <code>std::commone_type_t</code> is exactly doing what I want to do. It take a variable and return a type (Which is type of that variable).</p>
  
  <p>How can I define that? Can I implement it with <code>std::commone_type_t</code> or a better solution, just with <code>templates</code>?</p>