28 Mar
2008
28 Mar
'08
10:33 a.m.
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