Boost logo

Boost Users :

Subject: Re: [Boost-users] multi_index_comtainer questions
From: joaquin_at_[hidden]
Date: 2009-10-19 10:53:13


Vladimir Voronkov escribió:
> I understand the idea with exposing interval for interator. This is not always useful. For example I implement some class with this container as a private member. I would expose useful interface from this class which hides all work with these flags as well as data representation. And at the same time I would like to avoid copying data into another container just to expose the necessary data. Imagine the following function.
>
> UsersSelected& MyClass::GetSelectedUsers() const
> {
> return m_container.get<2>(--- here we would put some condition ---);
> }
>
> Client of this code might not be aware of what container "UsersSelected" is, and just use it as regular set. This interface seems me more elegant then returning range of iterators because client should know what lies behind these iterators.
>
[Please don't top-post, see
http://www.boost.org/community/policy.html#quoting ]

I understand your position, and the short answer is that
Boost.MultiIndex does
not provide such a facility. A longer answer is, I don't really see this
pseudo-
container approach more beneficial than exposing a pair of iterators,
because
ranges (pair of iterators) are the preferred way to let different pieces
of code
communicate. This is the cornerstone of the STL design. Of course you might
legitimately disagree.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net