Boost logo

Boost :

From: Martin Schulz (Martin.Schulz_at_[hidden])
Date: 2007-07-24 13:11:57

> For the sake
> of hacking together proxies that work with algorithms which
> expect STL containers, providing the nested typedefs may be
> the only option to optimize code reuse, but in those cases,
> you have to realize that what you would be doing truely is a
> hack, since a proxy itself is not a valid STL container type
> and therefore shouldn't be passed to algorithms where one is expected.

I tend to disagree. I think of an proxy object not so much as a
but rather as a "drop-in replacement" that happens by chance to be
to some other container object, but that is only an implementation

If the proxy models an STL container then it should work with any STL or

other appropriate algorithm and I do not consider this a hack.
It simply works as designed.

Therefore I favor option 1).
Clearly a non-const proxy may not be constructed from a const container.

When I pass some container-alike object into some method e.g. as const
I do not expect its contents to be modifyable.

For some more thoughts about const and non-const iterators, see also


Dr. Martin Schulz (schulz_at_[hidden])
Software Engineer 
Synopsys GmbH 
Karl-Hammerschmidt-Str. 34
D-85609 Dornach, Germany
Phone: +49 (89) 993-20203

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