迭代器概念弱于相应的命名要求,哪些适用于非范围标准算法?

Iterator concepts are weaker than the corresponding named requirements, which ones apply to the non-range standard algorithms?

在 C++20 中,我们获得了迭代器类别的概念,例如std::forward_iterator corresponds to named requirement ForwardIterator.

它们不等价。在某些(但不是全部)方面,概念较弱:

新的 std::ranges 算法似乎使用这些概念来检查迭代器要求。

但是其他标准算法呢? (存在于 C++20 之前)

他们在 C++20 中是否仍然使用与 C++20 之前相同的迭代器要求,或者对他们的要求是否放宽以匹配概念?

Do they still use the same iterator requirements in C++20 as they were pre-C++20, or did the requirements for them get relaxed to match the concepts?

现有的std::算法仍然使用命名要求。例如,[alg.find] 有两个:

template<class InputIterator, class T>
  constexpr InputIterator find(InputIterator first, InputIterator last,
                               const T& value);

template<input_­iterator I, sentinel_­for<I> S, class T, class Proj = identity>
  requires indirect_­binary_­predicate<ranges::equal_to, projected<I, Proj>, const T*>
  constexpr I ranges::find(I first, S last, const T& value, Proj proj = {});
template<input_­range R, class T, class Proj = identity>
  requires indirect_­binary_­predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
  constexpr borrowed_iterator_t<R>
    ranges::find(R&& r, const T& value, Proj proj = {});

所有算法也是如此。


请注意,有人提议对此进行更改:Ranges views as inputs to non-Ranges algorithms。该论文将更改命名要求以符合 concepts(请注意,它将 而不是 更改 std:: 算法以接受哨兵)。