
10 Apr
2010
10 Apr
'10
9:40 p.m.
On 10 April 2010 17:22, Hicham Mouline
Given a std::vector<T> and a Compare<T> comparator, how can I:
1. determine the number of different elements in the vector? 2. get iterators to the list of distinct elements in the vector?
With 2 iterators b and e, std::sort(b, e); m = std::unique(b, e, Compare<T>()); Then you have the std::distance(b, m) unique elements available in the range [b, m). (Note that as a generic C++ question, this boost-specific list is perhaps not the best place to ask. You might consider something like Freenode's ##C++ IRC channel instead, where the medium means you would likely get a faster response as well, as the question doesn't require investigation or bug-hunting.)