no-throw-input-iterator, no-throw-forward-iterator, no-throw-sentinel-for, no-throw-input-range, no-throw-forward-range
来自 cppreference.cn
template< class I > concept no-throw-input-iterator = |
(1) | (仅为解释目的*) |
template< class I > concept no-throw-forward-iterator = |
(2) | (仅为解释目的*) |
template< class S, class I > concept no-throw-sentinel-for = std::sentinel_for<S, I>; |
(3) | (仅为解释目的*) |
template< class R > concept no-throw-input-range = |
(4) | (仅为解释目的*) |
template< class R > concept no-throw-forward-range = |
(5) | (仅为解释目的*) |
这些仅为解释目的的概念指定了在迭代器、哨位和范围的算法所需操作中不会抛出异常。
1) no-throw-input-iterator 概念要求解引用迭代器会产生一个左值,例如
contiguous_iterator
和 LegacyForwardIterator。[编辑] 语义要求
与所有标准概念一样,只有当此处列出的每个概念所包含的所有概念都建模时,该概念才会被建模。
1) 类型
I
只有在从递增、复制构造、移动构造、复制赋值、移动赋值或通过有效迭代器进行间接引用时不抛出异常时,才建模 no-throw-input-iterator。3) 类型
S
和 I
只有在从复制构造、移动构造、复制赋值、移动赋值或类型 I
和 S
的有效值之间的比较中不抛出异常时,才建模 no-throw-sentinel-for。4) 类型
R
只有在对类型 R
的对象调用 ranges::begin
和 ranges::end
时不抛出异常时,才建模 no-throw-input-range。[编辑] 注释
这些概念允许对迭代器和哨位的一些操作抛出异常,例如对无效值的操作。
[编辑] 参见
(C++20) |
指定类型为输入迭代器,即可以读取其引用的值,并且可以进行前置和后置递增 (概念) |
(C++20) |
指定 input_iterator 是前向迭代器,支持相等比较和多趟(概念) |
(C++20) |
指定类型是 input_or_output_iterator 类型的哨位(概念) |
(C++20) |
指定范围的迭代器类型满足 input_iterator (概念) |
(C++20) |
指定范围的迭代器类型满足 forward_iterator (概念) |