命名空间
变体
操作

no-throw-input-iterator, no-throw-forward-iterator, no-throw-sentinel-for, no-throw-input-range, no-throw-forward-range

来自 cppreference.cn
< cpp‎ | memory
 
 
内存管理库
(仅为解释目的*)
未初始化内存算法
(C++17)
(C++17)
(C++17)
受约束的未初始化
内存算法
C 库

分配器
内存资源
垃圾回收支持
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
未初始化存储
(直到 C++20*)
(直到 C++20*)
显式生命周期管理
 
template< class I >

concept no-throw-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 no-throw-forward-iterator =
    no-throw-input-iterator<I> &&
    std::forward_iterator<I> &&

    no-throw-sentinel-for<I, I>;
(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 =
    ranges::range<R> &&
    no-throw-input-iterator<ranges::iterator_t<R>> &&

    no-throw-sentinel-for<ranges::sentinel_t<R>, ranges::iterator_t<R>>;
(4) (仅为解释目的*)
template< class R >

concept no-throw-forward-range =
    no-throw-input-range<R> &&

    no-throw-forward-iterator<ranges::iterator_t<R>>;
(5) (仅为解释目的*)

这些仅为解释目的的概念指定了在迭代器、哨位和范围的算法所需操作中不会抛出异常。

1) no-throw-input-iterator 概念要求解引用迭代器会产生一个左值,例如 contiguous_iteratorLegacyForwardIterator

[编辑] 语义要求

与所有标准概念一样,只有当此处列出的每个概念所包含的所有概念都建模时,该概念才会被建模。

1) 类型 I 只有在从递增、复制构造、移动构造、复制赋值、移动赋值或通过有效迭代器进行间接引用时不抛出异常时,才建模 no-throw-input-iterator
3) 类型 SI 只有在从复制构造、移动构造、复制赋值、移动赋值或类型 IS 的有效值之间的比较中不抛出异常时,才建模 no-throw-sentinel-for
4) 类型 R 只有在对类型 R 的对象调用 ranges::beginranges::end 时不抛出异常时,才建模 no-throw-input-range

[编辑] 注释

这些概念允许对迭代器和哨位的一些操作抛出异常,例如对无效值的操作。

[编辑] 参见

指定类型为输入迭代器,即可以读取其引用的值,并且可以进行前置和后置递增
(概念) [编辑]
指定 input_iterator 是前向迭代器,支持相等比较和多趟
(概念) [编辑]
指定类型是 input_or_output_iterator 类型的哨位
(概念) [编辑]
指定范围的迭代器类型满足 input_iterator
(概念) [编辑]
指定范围的迭代器类型满足 forward_iterator
(概念) [编辑]