Namespaces
Variants
Views
Actions

Talk:cpp/algorithm

From cppreference.com
< Talk:cpp
Revision as of 05:35, 19 September 2014 by Gemini67 (Talk | contribs)

Simple question: Why is count() listed here and distance() listed in the iterators library?--Gemini67 (talk) 06:35, 19 September 2014 (PDT)

The most direct answer is probably that std::count is a part of the algorithms library in C++ (chapter 25 of the standard), while std::distance is part of the Iterators library (chapter 24 of the standard). They are also declared in different headers. Note that std::count does something with the elements of a sequence, while std::distance operates on iterators only. --Cubbi (talk) 04:21, 19 September 2014 (PDT)
Thank you for the detailed explanation.
However, the question arose because I was looking for a count() without a condition == distance(). But I never used distance() before so I did not think about it ...
Is it possible to add a link to the iterators library, saying something like 'for more operations on iterators look here'?--Gemini67 (talk) 06:35, 19 September 2014 (PDT)