Topic: ownership pointers


Author: fknauss@qualcomm.com (Friedrich Knauss)
Date: 1996/08/28
Raw View
There has been much discussion on the behavior of auto_ptrs,
both in this forum, and apparently (according to the recent
changes in the draft) in the standards committee as well.

Many of the other features of C++ were designed to be
extensible, with the STL being a shining feature of this.
Algorithms may be used with iterators, regardless of whether the
iterators come from STL containers, or home grown ones. I
consider this to be a good thing.

The concept of ownership pointers, however starts and stops at
the auto_ptr. There are other types of ownership pointers, the
most commonly mentioned being a reference counting pointer,
but other flavors have also been brought up.

All of the comments I have seen to date have concerned
themselves with finding the "perfect" ownership pointer. The
auto_ptr advocates tout simplicity and low overhead, count_ptr
advocates like the shareability. The fact of the matter is, that
like choosing an STL container, the choice of ownership pointer
is best determined by the situation in which it will be used.
Unlike STL containers, they cannot be easily interchanged. Given
the current proposed public interface, I cannot (easily)
transfer ownership from an auto_ptr to a count_ptr or a freezing
auto_ptr. Furthermore, I cannot transfer that ownership  back to
an auto_ptr once I am done with it.

I suspect it is too late to do much about this, but given the
abilities of the language it should have been quite possible to
provide more flexibility in this feature of the standard library
than actually has been. Of course, it is entirely possible that
I've missed the intent of the comittee, and that I'm merely
blind to the flexibility which I seek. In that case I would
appreciate enlightenment from a guru with spare time (should
such a thing exist).


--
-- fritzz@qualcomm.com
-- Pain is temporary, glory is forever.
--
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]