|
| kunigami (14) | |
| Hi all! I'd like to know if C++ STL has a way to count elements in a certain range from a set. I tried using lower_bound/upper_bound, but I couldn't subtract a set<int>::iterator from another. Is there any other way to do that using STL? Thank you very much, | |
| Bazzy (4120) | |
| Try set::size or set::count http://www.cplusplus.com/reference/stl/set/ | |
| seymore15074 (449) | |
| Like distance? http://www.cplusplus.com/reference/std/iterator/distance.html Just be sure to read the information and make sure it works with the container you are using... | |
| jsmith (3807) | |||
Another way is via std::count_if and boost::lambda (the boost::lambda just allows me to do this with one line of code instead of writing a function object):
| |||
| seymore15074 (449) | |
| Man, I've got to learn boost::lambda...I read through some of the information at boost.org, but I still haven't actually used it in my own code for anything... Is that the same one that has the bind stuff? | |
| jsmith (3807) | |
| boost::lambda has its own version of bind, but there is also the boost::bind library. It's cool, but has a steep learning curve. | |
This topic is archived - New replies not allowed.
