user17175449
user17175449

Reputation:

How should I assume which iterator category an algorithm uses?

Let's say :

std::sort(beg1, beg2, pred);

This algorithm takes a range of iterators for the container and a predicate. It takes an LegacyRandomAccessIterator. I do understand the the 5 iterator categories are categorised by their operators. Albeit I'm having a hard time assuming which iterator the algorithm uses.

Upvotes: 0

Views: 61

Answers (1)

Werner Henze
Werner Henze

Reputation: 16726

There is no need to assume anything, it is all documented. According to cppreference the iterators are LegacyRandomAccessIterator.

Type requirements
-RandomIt must meet the requirements of ValueSwappable and LegacyRandomAccessIterator.
-The type of dereferenced RandomIt must meet the requirements of MoveAssignable and MoveConstructible.

The page for LegacyRandomAccessIterator describes what such an iterator looks like.

Upvotes: 2

Related Questions