cout number of elementsbetween two iterators
cout number of elements between two iterators
i have
cit = unique(mcit->begin(),mcit->end(),cmpeqrank);
and now i want to count between
mcit->begin() and cit to see how many unique elements there are.
i tried the stl template functions count_if and count but they count only elements which are equal to a result when i just want to count all elements.
Hi
you can use count_if with an unary predicate the always returns true, this should could all elements in the range [beg,end)
Edit: You should use Mc Cloud's method, and if you are using random access iterators you can simply subtract them just as you can it with pointers.
you can use count_if with an unary predicate the always returns true, this should could all elements in the range [beg,end)
Edit: You should use Mc Cloud's method, and if you are using random access iterators you can simply subtract them just as you can it with pointers.
thankyou very much!! may ask where you found this function i could not find it on
http://cppreference.com/all_cpp_functions.html
http://cppreference.com/all_cpp_functions.html
There s an excellent book about the STL:
The C++ Standard Library: A Tutorial and Reference
by Nicolai M.Josuttis
ISBN:0-201-37926-0
$59.99
Its worth the money
The C++ Standard Library: A Tutorial and Reference
by Nicolai M.Josuttis
ISBN:0-201-37926-0
$59.99
Its worth the money
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement