Boost logo

Boost :

Subject: Re: [boost] Review of a safer memory management approach for C++?
From: Fernando Cacciola (fernando.cacciola_at_[hidden])
Date: 2010-06-03 23:14:25

Hi David,

>> Trying to over design a program to avoid all shared ownership is
>> what make C++ programming so unproductive and has all the negative
>> consequences described in Section 1 in:
>> Designs with object sharing can be much less complex overall than
>> designs with sharing. You just need decent tools to detect circular
>> reference problems (and that is what the Teuchos::RCP class has).
> Well, I fundamentally disagree with all of the above. Overuse of
> runtime polymorphism, thus dynamic allocation, and thus shared
> ownership (it's almost an inevitable progression) is one of the things
> that has made C++ programming unproductive, and those people I know
> who most zealously avoid it tend to be more productive than everyone
> else. IMO.
I couldn't agree more.

C++ best practices has been evolving from dynamically-polymorphic designs to
statically-polymorphic ones, but rather slowly, so I don't expect to see most
competent programmers do the mental migration just yet. This requires a
mindshift comparable to that of structured -> OO programming.
I even wonder if this isn't a new paradigm altogether.

For instance, it's been so long since I last wrote a virtual function that
recently, I made the silly mistake of forgetting that, in a derived class, an
overrided function doesn't have to specify the virtual keyword ;)


Speaking of value-semantics and moving (as opposed to sharing) objects... I
recall a CUJ article in the mid 90's with a smart pointer offering a handle/body
solution for value-semantics of dynamically allocated objects. I don't remember
the details (such as using COW or what), nor the author, but I do remember that
it was, IMO, simply brillant, but way ahead of its time. Compilers at the time
could barely template two and two toghether, so the actual utility was rather

I just thought that, maybe, C++0x finally got what it takes to tackle on
something like that?

IMO this would make for a terrific boost project, to the level of what
shared_ptr used to be 15 years ago.

Anyone? (I can't get into something like that without a time machine I'm afraid :)


Fernando Cacciola
SciSoft Consulting, Founder

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