Boost logo

Boost Users :

From: Daniel Lidström (daniel.lidstrom_at_[hidden])
Date: 2008-03-28 06:33:31


Hello Ovanes,

Ovanes wrote:
 
> Hello Daniel,
>
> I thought about such a class as well. The main disadvantage of it
> is that it is impossible to use with standard containers. :(
> Standard containers (e.g. std::vector) pre-allocate space for
> some number of instances and use the placement new operator to
> place items in the pre-allocated memory and when deriving form
> nondynamic makes it impossible.

As I understand it, the standard containers use the global placement new,
which cannot be overridden. These lines are actually ok to do it seems:

   char dataIOBuffer[sizeof(DataIO)] = {0};
   DataIO* inplaceCreated = ::new(dataIOBuffer)DataIO(IDataIOPtr());

Regardless of where I place (no pun intended) the placement new operator
in nondynamic.

-- 
Daniel

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net