 <p>Function templates <a href="http://stackoverflow.com/a/22411782/2567683">mix weirdly with overloading</a>.</p> <p>A possible solution (not the unique) would be to use <code>enable_if</code> for the declaration of each function enalbing the second for pointer types and vise versa for the first</p> <pre><code>#include &lt;type_traits&gt; template &lt;class TO, class FROM&gt; FORCE_INLINE typename enable_if&lt;!is_pointer&lt;FROM&gt;::value, TO&gt;::type punning_cast(const FROM &amp;input) { ... } template &lt;class TO, class FROM&gt; FORCE_INLINE typename enable_if&lt;is_pointer&lt;FROM&gt;::value, TO&gt;::type punning_cast(const FROM input) { ... } </code></pre> <p>So an example of achieving the dissambiguation (between reference and pointer) would be <a href="http://ideone.com/xsbd55" rel="nofollow"><strong>this one</strong></a></p>