Boost logo

Boost :

From: Ralf W. Grosse-Kunstleve (rwgk_at_[hidden])
Date: 2006-03-10 02:25:39


--- Howard Hinnant <howard.hinnant_at_[hidden]> wrote:

> > Note that I don't want reference counting overhead (shared_array)
> > or the
> > overhead associated with std::vector (two pointers instead of just
> > one, default
> > construction on resize or lots of push_backs, deepcopy semantics).
>
> Point your vendor at:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/
> n1856.html#Addition%20-%20Class%20template%20unqiue_ptr
>
> and tell them you want it sooner rather than later.

Thanks for the link! unique_ptr looks like the best general solution. Problem
is, I needed it yesterday (literally) and in fact I would have loved to use it
many times before.

If auto_ptr is going to be deprecated, of course auto_array shouldn't be in
boost. How about this tiny patch then to keep poor old scientific application
developers like me going until the optimal solution is universally available?

Index: scoped_array.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/scoped_array.hpp,v
retrieving revision 1.16
diff -u -r1.16 scoped_array.hpp
--- scoped_array.hpp 19 Aug 2004 15:23:46 -0000 1.16
+++ scoped_array.hpp 10 Mar 2006 07:12:35 -0000
@@ -37,10 +37,12 @@
 
 template<class T> class scoped_array // noncopyable
 {
-private:
+protected:
 
     T * ptr;
 
+private:
+
     scoped_array(scoped_array const &);
     scoped_array & operator=(scoped_array const &);
 

Those in danger of abusing release() most likely won't notice that they can
inherit, implement release() in the sub-class, and only then start abusing. But
I'd be a happy chap because I wouldn't have to copy scoped_array.hpp wholesale.

BTW: The scoped_ptr FAQ should be changed to point to the unique_ptr page.
Otherwise people like me will keep thinking auto_ptr is a good thing.

Thanks!

Cheers,
        Ralf

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


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