Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-03-05 09:04:56

One last thing:

> > 8. maybe you should add const_pointer data() const
> ?
> It is not possible. data() is mutating operation.
> See
> the source code.
> ---------------
> ok. then maybe one should get more hints about this
> mutation (I did not have
> a clue), maybe like
> c.prepare_array();
> foo( &*c.begin() );
There are some words regarding iterator invalidation
in the method documentation.
ok, I'm not super religious about it, but my line of thought goes like this:

if a programmer sees this kind of code:

circular_buffer<T> cb;
foo( );

he would have to look at documentation to know what's going on (he could be
a maintenance programmer who have no
earlier knowlegde of circular buffer). data() is a very
innocent word and I doubt that people in general would think all iterator
were invalidated. I also doubt that they would think
it was a linear time operation. Now, that's why I think it might be possible
to give programmer just a little more hint about
what might be going on by using a *verb* in the functions name, eg.


It's probably good to get other's oppinion about this too.



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