|
Boost : |
From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-07-17 04:39:20
> > From: Philippe A. Bouchard [mailto:philippeb_at_[hidden]]
> > "David B. Held" <dheld_at_[hidden]> wrote in message
> > news:ah0cl8$tqu$1_at_main.gmane.org...
[...]
> This usage of 'mutable' was rejected because it has the side effect that
two
> copies of an object are not equivalent. This, in turn, can cause nasty
> side-effects if you use mutable_ptr with Standard containers and
algorithms.
Yeah I know, this is why 'mutable' was in the class name; to warn developer
from its side effects.
> While you can usually get away with using it in containers (although it's
> not technically portable), the real problem comes in using it with
> algorithms:
mutable_ptr<> should have restricted usages for primitive operations like
container copyings and destructions. Advantageous example:
class entry
{
virtual ~entry() {}
};
class company : entry
{
string name;
list< mutable_ptr<entry> > affected_contracts;
};
class scientist : entry
{
string name;
};
list< mutable_ptr<entry> > transactions;
You can see here that you could read a file into a list<> and transform it
into a vector<> when you know its final size. You'll also notice by
yourself that destructions will be done cleanly.
[...]
Philippe A. Bouchard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk