<div dir="ltr">I was poking through the black magic in Casting.h, and I see this interesting struct/function:<div><br></div><div><pre style="font-family:Consolas;color:gainsboro;background:rgb(30,30,30)"><span style="color:rgb(86,156,214)">template</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(86,156,214)">class</span> <span style="color:rgb(78,201,176)">To</span><span style="color:rgb(180,180,180)">,</span> <span style="color:rgb(86,156,214)">class</span> <span style="color:rgb(78,201,176)">FromTy</span><span style="color:rgb(180,180,180)">></span> <span style="color:rgb(86,156,214)">struct</span> <span style="color:rgb(78,201,176)">cast_convert_val</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(78,201,176)">To</span><span style="color:rgb(180,180,180)">,</span><span style="color:rgb(78,201,176)">FromTy</span><span style="color:rgb(180,180,180)">,</span><span style="color:rgb(78,201,176)">FromTy</span><span style="color:rgb(180,180,180)">></span> <span style="color:rgb(180,180,180)">{</span>
  <span style="color:rgb(87,166,74)">// This _is_ a simple type, just cast it.</span>
  <span style="color:rgb(86,156,214)">static</span> <span style="color:rgb(86,156,214)">typename</span> <span style="color:rgb(78,201,176)">cast_retty</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(78,201,176)">To</span><span style="color:rgb(180,180,180)">,</span> <span style="color:rgb(78,201,176)">FromTy</span><span style="color:rgb(180,180,180)">>::</span><span style="color:rgb(78,201,176)">ret_type</span> <span style="color:rgb(200,200,200)">doit</span><span style="color:rgb(180,180,180)">(</span><span style="color:rgb(86,156,214)">const</span> <span style="color:rgb(78,201,176)">FromTy</span> <span style="color:rgb(180,180,180)">&</span><span style="color:rgb(127,127,127)">Val</span><span style="color:rgb(180,180,180)">)</span> <span style="color:rgb(180,180,180)">{</span>
    <span style="color:rgb(86,156,214)">typename</span> <span style="color:rgb(78,201,176)">cast_retty</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(78,201,176)">To</span><span style="color:rgb(180,180,180)">,</span> <span style="color:rgb(78,201,176)">FromTy</span><span style="color:rgb(180,180,180)">>::</span><span style="color:rgb(78,201,176)">ret_type</span> <span style="color:rgb(200,200,200)">Res2</span>
     <span style="color:rgb(180,180,180)">=</span> <span style="color:rgb(180,180,180)">(</span><span style="color:rgb(86,156,214)">typename</span> <span style="color:rgb(78,201,176)">cast_retty</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(78,201,176)">To</span><span style="color:rgb(180,180,180)">,</span> <span style="color:rgb(78,201,176)">FromTy</span><span style="color:rgb(180,180,180)">>::</span><span style="color:rgb(78,201,176)">ret_type</span><span style="color:rgb(180,180,180)">)</span><span style="color:rgb(86,156,214)">const_cast</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(78,201,176)">FromTy</span><span style="color:rgb(180,180,180)">&>(</span><span style="color:rgb(127,127,127)">Val</span><span style="color:rgb(180,180,180)">);</span>
    <span style="color:rgb(86,156,214)">return</span> <span style="color:rgb(200,200,200)">Res2</span><span style="color:rgb(180,180,180)">;</span>
  <span style="color:rgb(180,180,180)">}</span>
<span style="color:rgb(180,180,180)">};</span>
</pre></div><div>Why is the C-style cast needed? <br></div><div><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><span style="font-size:12.8000001907349px">Sincerely,</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">Alexander Riccio</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">--</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">"Change the world or go home."</span><div style="font-size:12.8000001907349px"><a href="http://about.me/ariccio" target="_blank">about.me/ariccio</a></div><div style="font-size:12.8000001907349px"><a href="http://about.me/ariccio" target="_blank"><br></a></div><div style="font-size:12.8000001907349px">If left to my own devices, I will build more.</div><div style="font-size:12.8000001907349px">⁂</div></div></div></div></div></div>
</div></div>