title: How can I specialise a template function designed to return different types?
body: <p>I currently have a function template that reads a string obtained from a configuration file and creates and returns a shared pointer to a new instance of a derived class:</p>
  <pre><code>template &lt;typename T&gt; std::shared_ptr&lt;T&gt; foo(std::string&amp; info)
  { /* */ }
  </code></pre>
  <p>I would like to specialise this when I return a particular class, because it needs to handle the string differently, but I can't find a way of doing it.
  Trying</p>
  <pre><code>std::shared_ptr&lt;Derived&gt; foo(std::string&amp; info)
  {/* */}
  </code></pre>
  <p>and</p>
  <pre><code>template &lt;&gt; std::shared_ptr&lt;Derived&gt; foo(std::string&amp; info)
  {/* */}
  </code></pre>
  <p>both fail because I appear to be breaking the one definition rule.
  I've also tried</p>
  <pre><code>template &lt;&gt; std::shared_ptr&lt;Derived&gt; foo&lt;std::shared_ptr&lt;Derived&gt;&gt;(std::string&amp; info)
  {/* */}
  </code></pre>
  <p>but I received Visual Studio error message C2192 (explicit specialization 'declaration' is not a specialization of a function template).</p>