|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2006-07-06 18:22:28
Thorsten Ottosen <thorsten.ottosen_at_[hidden]> writes:
> I have worked with C++, Java and C# for years, also on big projects,
> and object cloning have never been a major part of the code,
> although the code was OO all the way.
Probably that was precisely because the code was "OO all the way,"
which in your mind means reference semantics.
There's an important category of types that synergizes OO and generic
approaches, for example (function is one). If you maintain the rigid
ideology that OO and value semantics don't go together, of course
you're never going to see them together, and putting them together
will never make sense to you.
boost::function is perhaps the 2nd simplest case of a category of
types that essentially captures value semantics polymorphically, with
boost::any being the simplest. boost::function essentially adds one
virtual function (the function call operator), but there's nothing
special about the number 1.
Incidentally, just to press the point that value semantics and runtime
polymorphism aren't mutually exclusive, here's another point along
the OO/value semantics continuum that can use shared_ptr instead of
clone_ptr: immutable polymorphic pimpls.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk