|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-04-27 13:03:23
"Thorsten Ottosen" <nesotto_at_[hidden]> writes:
> "David Abrahams" <dave_at_[hidden]> wrote in message
> news:uk6mo2ylf.fsf_at_boost-consulting.com...
> | "Thorsten Ottosen" <nesotto_at_[hidden]> writes:
> |
> | > A "value object" implies something that behaves as an int; a
> | > "polymophic object" implies something that needs to allocated
> | > dynamically and which has virtual functions.
> |
> | A polymorphic object doesn't need to be allocated dynamically.
>
> if you want it to act polymophic you have to.
int f(Base& b)
{
return b.some_virtual_function(); // acts polymorphically
}
Derived d; // not dynamically allocated.
int x = f(d);
> | > trying to make a polymorphic object behave like a value object is
> | > confusing a best.
> |
> | Who does it confuse? Pimpl is a commonly used and well understood
> | pattern for doing just that.
>
> Pimpl is an ugly hack for compilation firewalls.
It's a standard way to hide polymorphic behavior behind a
statically-typed interface. Arguing that it is an ugly hack is just a
distraction from the point at hand, so I'll ask again: Who is confused
by Pimpl?
-- 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