|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-07-11 17:48:36
"Peter Dimov" <pdimov_at_[hidden]> writes:
> David Abrahams wrote:
>> Andrey Melnikov <melnikov_at_[hidden]> writes:
>>
>>> David Abrahams wrote:
>>>> Andrey Melnikov <melnikov_at_[hidden]> writes:
>>>>
>>>>> char bar_placeholder[sizeof(std::string];
>>>>> std::string *bar = reinterpret_cast<std::string*>(bar_placeholder);
>>>>
>>>>
>>>> reinterpret_cast is nonportable.
>>>
>>> Why? I don't see any reasons why reinterpert_cast from char [] to
>>> std::string * could be nonportable.
>>
>> The standard says so. It's implementation-defined.
>
> I know that this is your favorite,
It's right up there with the greats ;-)
I also claim that most people get the relative safeness of static_cast
and const_cast backwards ;-)
> but in my opinion, "implementation defined" doesn't equal
> "nonportable" in this particular case. (Alignment problems
> notwithstanding.)
There's "nonportable according to the standard" and "nonportable in
practice." This one is only the former, it's true. But why write
something that might turn out to be nonportable somewhere when we can
do something that the standard guarantees?
-- Dave Abrahams Boost Consulting 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