Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-09-05 12:23:35


Bronek Kozicki <brok_at_[hidden]> writes:

> Rob Stewart wrote:
>
>>> static_assert<sizeof(Functor*) == sizeof(void *)> size;
> ^^^^^^^^^^^^^
>>>
>>> union convert
>>> {
>>> Functor* f;
>>> void* p;
>>> };
>
>> What if a void * and a pmf are not the same size? You at least
>> need a static assertion to that effect, right?
>
> Yep. I believe that it's rare, but in any case assertion is in place.

Why mess around? You don't need to use a void*; just use a
void(X::*)(void) for any X. Round-trip reinterpret_cast is
guaranteed to work.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk