|
Boost Users : |
Subject: Re: [Boost-users] boost::bind and Motif
From: Richard (legalize+jeeves_at_[hidden])
Date: 2012-05-04 20:26:52
[Please do not mail me a copy of your followup]
boost-users_at_[hidden] spake the secret code
<20120504195312.GC12377_at_[hidden]> 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>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net