"Peter Dimov" <[EMAIL PROTECTED]> writes:

| From: "Gabriel Dos Reis" <[EMAIL PROTECTED]>
| > David Abrahams <[EMAIL PROTECTED]> writes:
| >
| > | Gabriel Dos Reis <[EMAIL PROTECTED]> writes:
| > |
| > | > Hmm, I have a couple of questions answers to which will help me
| > | > get your point.
| > | >
| > | >  1) Why can't you do that with reinterpret_cast?
| > |
| > | You can, but the results are non-portable
| >
| > No more non-portable than with dangerous_cast<>.
| 
| I think that Dave's point is that in
| 
| new(h.storage) Foo;
| 
| there is a char* -> void* implicit conversion as placement new takes a
| void*. So the placement new performs char* -> void* -> Foo* (by constructing
| a Foo at (void*)h.storage), which - in theory - might not be the same as
| char* -> Foo*.

But then, that theoretical implementation can remember the type from
which the conversion to void* was made and may issue an error when an
attempt is made to dereference the pointer obtained by recasting the
result of static_cast<void*>(h.storage) to Foo*.

Practical notes:
Historically, char* was used as the type of "raw memory" until "void*"
was invented.  And since then char* and void* continues to have the
same properties as raw-memory issues are concerned.


-- Gaby

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to