nothrow-input-iterator、nothrow-forward-iterator、nothrow-bidirectional-iterator、no-throw-input-range、nothrow-random-access-iterator
来自 zh.cppreference.net
template< class I >
concept /*nothrow-input-iterator*/ =
std::input_iterator<I> &&
std::is_lvalue_reference_v<std::iter_reference_t<I>> &&
std::same_as<std::remove_cvref_t<std::iter_reference_t<I>>,
std::iter_value_t<I>>;
|
(1) | (仅供说明*) |
template< class I >
concept /*nothrow-forward-iterator*/ =
/*nothrow-input-iterator*/<I> &&
std::forward_iterator<I> &&
/*nothrow-sentinel-for*/<I, I>;
|
(2) | (仅供说明*) |
template< class I >
concept /*nothrow-bidirectional-iterator*/ =
/*nothrow-forward-iterator*/<I> &&
std::bidirectional_iterator<I>;
|
(3) | (自 C++26 起) (仅供说明*) |
template< class I >
concept /*nothrow-random-access-iterator*/ =
/*nothrow-bidirectional-iterator*/<I> &&
std::random_access_iterator<I> &&
/*nothrow-sized-sentinel-for*/<I, I>;
|
(4) | (自 C++26 起) (仅供说明*) |
这些仅供说明的概念指定,对于专用 <内存>算法在迭代器上所需的操作,不会抛出异常。
/*nothrow-sentinel-for*/ 和 /*nothrow-sized-sentinel-for*/ 的定义请参见此页面。
语义要求
1) 类型
I 仅当对类型 nothrow-input-iterator 的有效迭代器进行递增、复制构造、移动构造、复制赋值、移动赋值或间接引用时不会抛出异常,才模拟I。3) 类型
I 仅当对类型 nothrow-bidirectional-iterator 的有效迭代器进行递减时不会抛出异常,才模拟I。4) 类型
I 仅当对类型 nothrow-random-access-iterator 的有效迭代器进行比较,或者对类型 I 和 - 的有效值进行 +、-=、+=、[]、I 运算符操作时不会抛出异常,才模拟std::iter_difference_t<I>。注解
这些概念允许对迭代器的某些操作抛出异常。
参阅
(C++20) |
指定一个类型是输入迭代器,即可以读取其引用的值,并且它可以进行前后自增 (概念) |
(C++20) |
指定 input_iterator 是前向迭代器,支持相等比较和多遍遍历 (概念) |
(C++20) |
指定一个 forward_iterator 是双向迭代器,支持向后移动 (概念) |
(C++20) |
指定一个 bidirectional_iterator 是随机访问迭代器,支持常数时间内的前进和下标操作 (概念) |