Namespaces
Variants
Views
Actions

Difference between revisions of "Talk:cpp/algorithm"

From cppreference.com
(Simply question: Why is distance() missing here?)
 
(because they do different things?)
Line 1: Line 1:
  
 
Simple question: Why is count() listed here and distance() listed in the iterators library?
 
Simple question: Why is count() listed here and distance() listed in the iterators library?
 +
:The most direct answer is probably that count is a part of the algorithms library in Standard C++, while distance is part of the Iterators library. 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. --[[User:Cubbi|Cubbi]] ([[User talk:Cubbi|talk]]) 04:21, 19 September 2014 (PDT)

Revision as of 03:21, 19 September 2014

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

The most direct answer is probably that count is a part of the algorithms library in Standard C++, while distance is part of the Iterators library. 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)