On 08/25/2012 07:39 PM, Ulrich Drepper wrote:
On Sat, Aug 25, 2012 at 7:37 PM, Jonathan Wakely <jwakely....@gmail.com> wrote:
But iterators don't have to imply non-sequential storage. Using
iterators instead of pointers would allow you to store them in a
std::deque, for example, or in a std::vector using
std::back_insert_iterator.
Yes, and this is already trivial to do with the operator() interface.
The fill() interface is needed for performance, everything else is
taken care by the operator() interface.
If you templatize the pointers as forward iterators there is nothing
preventing you from *calling* with pointers on C arrays. You then get
the benefit that all containers can use this interface as well. Plus you
have std::array which is a C array under th ehood.
I'm a little bit stuck on why vector would be slow if, say a caller used
reserve.
Maybe the cost of default initialization and then setting the number later?
Anyway, like the idea.
How we juggle adding new members vs. standards compliance is another
question. We could add underscores and put them in the gnu extension
namespace as we do with other extensions. We would then have these
lying around if (as I think they should) this gets standardized. Or we
could just put them in and risk being out of step if the LWG doesn't add
them. OTOH, if we added them it would create a precedent... Politics ;-)
Ed