
[Please do not mail me a copy of your followup] boost-users@lists.boost.org spake the secret code <20120504195312.GC12377@honecker.acc.umu.se> thusly:
On Fri, May 04, 2012 at 11:42:58AM -0700, Jeffrey Lee Hellrung, Jr. wrote:
Sorry, drifting off-topic, and I'm not sure what XtPointer is, but based on your comment above, it seems it is a void pointer, and you can indeed static_cast a void pointer to any other (object) pointer type (as long as you don't drop cv qualifiers).
In my last standard reading, the conclusion I came to was that the only cast through void that is sane is the one to the exact same type, or possibly to/from char.
Yes, this is the only one that is "sane", but it's not the only one that's allowed by the language. This business of C style callbacks taking a void* context parameter has been around for a very very long time. I remember doing it back with Xt/Motif in 1989. The "sane" thing to do is to make sure that you cast it back to the exact type you passed in when you registered the callback with Xt. The best way to express this in C++ is static_cast<>. -- "The Direct3D Graphics Pipeline" -- DirectX 9 version available for download http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/ Legalize Adulthood! http://legalizeadulthood.wordpress.com