命名空间
变体
操作

operator==(std::counted_iterator<I>, std::default_sentinel_t)

来自 cppreference.cn
 
 
迭代器库
迭代器概念
(C++20)
迭代器原语
算法概念和工具
间接可调用概念
常用算法要求
(C++20)
(C++20)
(C++20)
工具
(C++20)
迭代器适配器
范围访问
(C++11)(C++14)
(C++14)(C++14)  
(C++11)(C++14)
(C++14)(C++14)  
(C++17)(C++20)
(C++17)
(C++17)
 
 
friend constexpr bool operator==(
    const counted_iterator& x, std::default_sentinel_t );
(自 C++20 起)

检查底层长度(即到末尾的距离)是否等于 0

此函数模板对于普通的非限定限定查找不可见,并且只有当 std::counted_iterator<I> 是参数的关联类时,才能通过实参依赖查找找到。

!= 运算符是从 operator== 合成 的。

目录

[edit] 参数

x - 一个迭代器适配器

[edit] 返回值

true 如果 x.count() 等于 0,则为 false,否则为否。

[edit] 示例

#include <initializer_list>
#include <iterator>
 
int main()
{
    static constexpr auto v = {1, 2, 3, 4};
    constexpr std::counted_iterator<std::initializer_list<int>::iterator>
        it1{v.begin(), 3},
        it2{v.begin(), 0};
    static_assert(it1 != std::default_sentinel);
    static_assert(it2 == std::default_sentinel);
    static_assert(std::default_sentinel != it1);
    static_assert(std::default_sentinel == it2);
}

[edit] 参见

比较到末尾的距离
(函数模板) [编辑]