|
Boost : |
From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2002-01-08 13:29:52
> Something that can be a drop-in replacement for char* buf = new
> char[n], with all the benefits of automated resource management.
>
> > and you're better off with simply calling
> > GetImpl(sp)[index] to index into the array.
>
> Huh? So, basically, you are saying that when one replace a pair
>
> char* buf = new char[n];
> ...
> delete[] buf;
>
> with
> LokiScopedArray<char>::type buf(new char[n]);
>
> she should also went through all the lines in between and replace buf[i]
to
> GetImpl(buf)[i], just because you decided that having an array notation is
> an unnecessary luxury? I would say that such attitude is unlikely to
attract
> too many users for your library.
Thanks for your kind words.
Same argument can apply to adding offsets to smart pointers to arrays. A
smart pointer to array should support a subset of pointer arithmetic (adding
offsets to the array) just as well as indexing. Why don't
boost::scoped_array and boost::shared array support adding offsets?
Andrei
---------------------------------
Check out THE C++ Seminar: 3 Days with 5 Experts
http://www.gotw.ca/cpp_seminar/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk