|
Boost : |
Subject: Re: [boost] [wave][function] Suppressing gcc-4.4.1 warnings
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2009-11-07 00:46:34
On Fri, Nov 6, 2009 at 11:51 PM, David Abrahams <dave_at_[hidden]> wrote:
>
> on Fri Nov 06 2009, Gottlob Frege <gottlobfrege-AT-gmail.com> wrote:
>
>> 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?
>
> Yes, exactly that way; and it's well-defined.
1. Is
static_cast<X *>(static_cast<void *>(&z))
really any better than
reinterpret_cast<X *>(&z)
?
In what way(s)? ie to me, they can both cause equal amounts of trouble.
2. What is left for reinterpret_cast to do? casting to/from ints to
pointers, etc? (useful in lockfree programming, etc). Which would be
better accomplished with unions I suppose.
In other words, What can reinterpret_cast do that other methods can't, and
a) if any unique abilities exist, are they always evil?
or
b) if no unique abilities exist, are the other methods equally evil?
Or by selecting particular methods (other than reinterpret) for each
use case are we just being more careful and more specific in our
intent?
Tony
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk