Alf P. Steinbach wrote:
* Samshayam@gmail.com:
C++ FAQ , says the following as application of placement new.
"For example, when your hardware has a memory-mapped I/O timer device,
and you want to place a Clock object at that memory location."
This is making a me again confused
As well it should: hardware is very seldom C++-oriented. Placing a POD
(C-like struct) at some memory address to access memory mapped hardware
is useful, but you don't need placement new for that. A non-POD object
can have "hidden" fields, like a vtable pointer, and also its fields can
be in an unpredictable order; using such an object for memory mapped i/o
is a recipe for disaster.
In short, the example, at <url:
http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.10>, seems to be
a leftover from some earlier editing, and in addition the 'new' in the
code there should be '::new'.
I still contend that ::new is unnecessary (cf.
http://groups.google.com/group/comp.lang.c++/browse_frm/thread/b656e66e030cd196).
if it just forwards to the global new).