Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2005-10-27 00:28:38

> struct people: vecperson
> {
> ///some methods only, no data
> ///nontrivial constructor as choir, but we still have
> /// sizeof(vecperson) == sizeof(people)
> };
> I submit that people is a concrete type, with no restrictions on
> newing deleting, or containing.

I do not question it is valid C++. It is also an example of bad practice.
people is not just a vector of person - I dare to submit they are much more.
Yet we could implement model of people using some collection of persons
(amoung other things). What I am trying to say is that here is a clear
example of confusion of "IMPLEMENTED WITH" relationthip with "IS A". And in
most cases when someine trying to inherit from collection this is the case.

> NOW if the question everyone else answered is can you do this?
> vecperson* pv = new people;
> delete pv;
> I _suspect_ that it will work just fine,
It will, but only for the definition above. As soon as you got nontrivial
destructor in people I _am sure_ it won't anymore

> but I'm not interested in
> that problem, nor was there any indication in the OP that it was a
> requirement.

My understanding is that making it work always was a primary goal of OP.

Boost list run by bdawes at, gregod at, cpdaniel at, john at