Re: Use of placement new in memory mapped i/o
* Samshayam@gmail.com:
> [top-posting, excessive quoting]
Please don't top-post in this group. Please don't quote excessively.
Please read the FAQ on how the post.
Thanks in advance.
* 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'.
CC: Marshall Cline (the FAQ maintainer).
Thanks: Marshall Cline, for maintaining the FAQ.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?