Boost logo

Boost :

From: Dave Abrahams (abrahams_at_[hidden])
Date: 2000-03-06 06:19:42

on 3/6/00 6:12 AM, Kevin Atkinson at kevinatk_at_[hidden] wrote:

> 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.
> };
> //
> #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.

Patience, my son. Some ideas need time to gain understanding and acceptance.
This is an intruiguing approach; I never thought to use explicit
instantiation... but I still don't see what prevents some other client of
foo from getting a compiler error here:

#include "foo.hh"
void f(Foo);
void g(const Foo& foo) {
    f(foo); // <-- illegal use of incomplete type 'Bar1'

>>>> 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 (
> for the very reason as demonstrated above.

Sorry, I _really_ must be missing something. How have you demonstrated the
need for non-owning CopyPtr above?


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