[llvm-dev] Question: C-style casting in Casting.h

<Alexander G. Riccio> via llvm-dev llvm-dev at lists.llvm.org
Sat Jan 30 15:04:49 PST 2016


I was poking through the black magic in Casting.h, and I see this
interesting struct/function:

template<class To, class FromTy> struct cast_convert_val<To,FromTy,FromTy> {
  // This _is_ a simple type, just cast it.
  static typename cast_retty<To, FromTy>::ret_type doit(const FromTy &Val) {
    typename cast_retty<To, FromTy>::ret_type Res2
     = (typename cast_retty<To, FromTy>::ret_type)const_cast<FromTy&>(Val);
    return Res2;
  }};

Why is the C-style cast needed?

Sincerely,
Alexander Riccio
--
"Change the world or go home."
about.me/ariccio

<http://about.me/ariccio>
If left to my own devices, I will build more.
⁂
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160130/9ca2a112/attachment.html>


More information about the llvm-dev mailing list