Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-09-28 10:01:01


Hi Dave,

"Dave Harris" <brangdon_at_[hidden]> wrote in message
news:memo.212883_at_cix.compulink.co.uk...
| In-Reply-To: <1256163046.20040926162826_at_[hidden]>
| I'm very dubious about using:
|
| vec.begin()->bar();
|
| instead of:
|
| (*vec.begin())->bar();
|
| It means that ptr_vector<T> is not syntactically a drop-in replacement for
| vector<T *> or vector<shared_ptr<T> >.

true.

| Won't that make it unnecessarily
| difficult to "upgrade" existing classes, and harder to switch back again
| should the need arise?

It has never been the intention to support a path of "upgrade". The semantics
are
very different from vector<shared_ptr<T> > and ptr_vector<T>. The semantics
are closer to vector<T> when it comes to "copying".

| Doesn't it also obscure what is going on? It seems
| a fundamentally wrong notation to me.

The indirected interface was made for a number of reasons, among others

- to hide the pointers so to protect against pointer manipolation
- to remove the obscure syntax of vector<T*>.
- to provide some interface closeness to vector<T>.

If you want the old syntax, you just call ptr_begin():

(vec.ptr_begin())->bar();

br

Thorsten


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