Boost logo

Boost :

Subject: Re: [boost] [wave][function] Suppressing gcc-4.4.1 warnings
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2009-11-06 22:32:46


On Fri, Nov 6, 2009 at 7:55 PM, David Abrahams <dave_at_[hidden]> wrote:
>
> Why is any Boost code using reinterpret_cast?  There's very little you
> can do portably with reinterpret_cast, and IIRC, what little you *can*
> do portably can also be done with static_cast.
>

Didn't check, but I think this case (flex_string) was probably doing
some kind of small buffer optimization. Regardless, consider
something like boost optional. Doesn't it hold a non-allocated buffer
for the optional T? The type of the buffer is probably char []. I
haven't tried it, but can you static_cast that to T? Via an
intermediate cast to void * or something?

(And do we know if static_cast would solve the original warnings?
This is orthogonal to whether we should ever use reinterpret_cast, of
course.)

P.S. I agree that its use should definitely be very limited.

Tony


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