Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-04-27 13:17:24


"Thorsten Ottosen" <nesotto_at_[hidden]> writes:

> "David Abrahams" <dave_at_[hidden]> wrote in message
> news:u8y342xnj.fsf_at_boost-consulting.com...
> | "Thorsten Ottosen" <nesotto_at_[hidden]> writes:
> |
> | > "Peter Dimov" <pdimov_at_[hidden]> wrote in message
> | > news:099701c54ab2$8f8fb080$6401a8c0_at_pdimov2...
> | > | Thorsten Ottosen wrote:
> | >
> | > | > I think you have to explain why they are not different then.
> | > | The burden of proof lies usually with the person making the
> | > | statement. ;-)
> | >
> | > no, the burden of proof lies on the person making the controversial
> | > statement; in this case you.
> |
> | Controversialness is in the eye of the beholder, and regardless,
> | Peter's right: by convention, the burden of proof lies with the
> | claimant.
>
> I disagree.

Then I will accept the burden of proof for my claim:
http://en.wikipedia.org/wiki/Burden_of_proof#Other_uses
http://www.nizkor.org/features/fallacies/burden-of-proof.html

> | That's very practical, because if you're saying something
> | so obvious and "uncontroversial" it should be very _very_ simple to
> | demonstrate it.
>
> Pick up you're favourite book on OO and on STL and see if the
> programming techniques look alike.

That's a very parsimonious explanation. It would be nice if you'd try
to make it a bit clearer in the context of the question of duplicating
objects, and show how it justifies a choice to prohibit ptr_containers
from acting like proper values.

> | > stuff like "value-based programming is not different from
> | > OO-programming"
> |
> | Nobody made that statement.
>
> Peter asked the question.

That's very different from making the claim.

> | The user can't tell a Pimpl with a polymorphic impl from one
> | without. They both just look like values, and all those
> | behavioral variations that are implemented with virtual functions
> | could just as well be implemented with "if" statements. Nobody
> | (except maybe you) has a problem with allowing pimpls to have copy
> | ctors -- impls often have clone() functions just to serve those
> | copy ctors. A ptr_container is almost exactly like a multi-pimpl
> | or a pimpl aggregate.
>
> I'm not prohibiting you from copying something with clone(), it just
> not the default behavior.

Are you not prohibiting a ptr_container from being copied with copy
syntax? Or have I misunderstood completely?

> | > polymorphic objects don't have value-based copy-semantics; you can't
> | > provide meaningful copy-constructor and copy-assignment operators.
> |
> | Sure they do. You only can't provide a meaningful copy ctor and copy
> | assignment for an abstract base class.
>
> and then you get the nice slicing behavior.

What slicing?

  struct Base
  {
      virtual ~Base();
      virtual void f() = 0;
   protected:
      Base(Base const&) {}
      Base& operator=(Base const&) {}
  };

  struct Derived : Base
  {
      virtual void f() {};

      Derived(Derived const& x)
        : Base(x) {}

      Derived& operator=(Derived const& x)
      { Base& self = *this; self = x; }
  };

Furthermore, pimpls copy and assign quite nicely.

-- 
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