Boost logo

Boost :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2006-08-21 09:27:30


Tal Agmon ha escrito:

> >Still I'm having difficulties with understanding your question, but let me
> > try my hand
>
> Your are good! :) I should knock myself for not sending you a snippet code
>
> below you can fiind a "small" example with only 2 indices

[...]

> // Now lets say I want to get a list of unique group_id values.
> // so I should get {10,20} event thought I have 3 elements
>
> //if i use the following
> [...]
> //Note that the for loop still iterates 3 times and not 2 times.
> // Meaning that the results of the key_extractor()(*it) key_value are
> {10,10,20}
> // My goal is to get back just {10,20} and not {10,10,20}

[...]

> I hope I made my point this time.

Yep, now it is much clearer, thanks. I've taken your snippet and filled in
a few bits (missing includes, missing typedef and declaration for index_t and
i, the key extractors' operator()'s were not const) and everything seems
to be working, both on GCC 3.2 and MSVC 6.5, the output is

10
20

like you require. I don't know how you're observing the loop iterating
thrice, here it does two steps as it should. Please check the attached
file to see if this solves your needs.

Best,

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




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