title: Is reinterpret_cast mostly useless?
body: <p>I've read various previous questions about <a href="https://stackoverflow.com/questions/573294/when-to-use-reinterpret-cast">the use of <code>reinterpret_cast</code></a>, and I've also read the relevant wording in the C++ standard.  Essentially, what it comes down to is that the result of a pointer-to-pointer <code>reinterpret_cast</code> operation can't safely be used for <em>anything</em> other than being cast back to the original pointer type.</p>
  
  <p>In practice, however, most real-world uses of <code>reinterpret_cast</code> seem to be based on the (wrong) assumption that a <code>reinterpret_cast</code> is the same as a C-style cast.  For example, I've seen lots of code which uses <code>reinterpret_cast</code> to cast from <code>char*</code> to <code>unsigned char*</code> for the purpose of character set conversion routines.  This is completely harmless, yet strictly speaking it's not portable - there's no guarantee that a <code>reinterpret_cast</code> from <code>char*</code> to <code>unsigned char*</code> won't crash your program when you try to dereference the <code>unsigned char*</code> pointer.</p>
  
  <p>It's seems the <em>only</em> other real use of <code>reinterpret_cast</code> that has any real guarantees, according to the standard, is converting from pointer to integer, and vice-versa.  </p>
  
  <p>And yet there are many cases where we'd <em>want</em> (and should be able to) safely convert between different pointer types.  For example: <code>uint16_t*</code> to the new C++0x <code>char16_t*</code>, or really any pointer to a basic data type that is the same size/alignment as the original type.  Yet <code>reinterpret_cast</code> provides no guarantees this should work.  </p>
  
  <p><strong>Question:</strong> How can we safely convert between pointers to basic data-types of the same size/alignment, such as <code>char*</code> --> <code>unsigned char*</code>?  Since <code>reinterpret_cast</code> doesn't seem to guarantee this actually works, are C-style casts the only safe option here?</p>