std::sized_sentinel_for, std::disable_sized_sentinel_for_C++中文网

  concept sized_sentinel_for =
    std::sentinel_for<S, I> &&
    !std::disable_sized_sentinel_for<std::remove_cv_t<S>, std::remove_cv_t<I>> &&
    requires(const I& i, const S& s) {
      { s - i } -> std::same_as<std::iter_difference_t<I>>;
      { i - s } -> std::same_as<std::iter_difference_t<I>>;

   

};

2) disable_sized_sentinel_for 变量模板能用于阻止能相减但不实际实现 sized_sentinel_for 的迭代器与哨位满足该概念。
允许对 cv 无限定的非数组对象类型 SI 特化该变量模板,只要其中之一是程序定义类型。这种特化必须可用于常量表达式并拥有 const bool 类型。

iI 类型迭代器,而 sS 类型哨位,使得 [i, s) 代表范围。令 n 为需要应用 ++i 以令 bool(i == s)true 的最小次数。则 sized_sentinel_for<S, I> 仅若符合下列条件才得到实现:

使用不修改某 const 左值运算数的表达式的 requires 表达式亦隐式要求该表达式的额外变种对给定运算数接受非 const 左值或(可为 const 的)右值,除非以有区别的语义显式要求这种表达式变种。这些隐式表达式变种必须符合与声明的表达式的相同的语义。不指定实现以何种程度校验变种的语法。