Boost logo

Boost :

From: Kevin Atkinson (kevinatk_at_[hidden])
Date: 2000-03-06 06:12:21


Dave Abrahams wrote:
>
> on 3/6/00 5:40 AM, Kevin Atkinson at kevinatk_at_[hidden] wrote:
>
> > No. Just don't include the "*-t.hh" header files. Include them
> > elsewhere where the definition of Pimpl is known and if nessary
> > instanstae the copy ptr for Pimpl.
>
> I don't believe in writing header files which, to be correctly compiled,
> require other headers to be manually included. This is simply too confusing
> and too much work for clients of an interface. With your technique it is
> valid to use Foo until you try to copy it. At that point you suddenly get
> compiler errors. That doesn't seem like a kind way to treat clients.

Simple example.

// foo.hh

#include "copy_ptr.hh"

class Bar1;
class Bar2;

class Foo {
  int x_;
  int y_;
  autil::CopyPtr<Bar1> bar1_;
  autil::CopyPtr<Bar2> bar2_;
 public:
  // other methods.
};

//foo.cc

#include "bar1.hh"
#include "bar2.hh"
#include "copy_ptr-t.hh"

namespace autil {
  template class CopyPtr<Bar1>;
  template class CopyPtr<Bar2>;
}

And that is ALL that is needed. No need to write any copy constructors,
assignment constructors, or destructors. This is why I think it makes
like simpler. If no one else agrees than so be it. I do not have time
to endlessly argue with you.

> >> Also, the idea that some CopyPtrs can own their target while others do not
> >> is worrisome to me. It certainly seems like an unneccessary complication and
> >> a good hole to drive bugs through.
> >
> > Well it works VERY well for me. Perhapes not for others.
>
> What do you use it for?

All over the place in my Aspell program (http://aspell.sourceforge.net/)
for the very reason as demonstrated above.

-- 
Kevin Atkinson
kevinatk_at_[hidden]
http://metalab.unc.edu/kevina/

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk