Namespaces
Variants
Views
Actions

Talk:cpp/algorithm

From cppreference.com
< Talk:cpp
Revision as of 04:55, 19 September 2014 by Cubbi (Talk | contribs)

Simple question: Why is count() listed here and distance() listed in the iterators library?

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)