std::ranges:: cend
|
定义于头文件
<ranges>
|
||
|
定义于头文件
<iterator>
|
||
|
inline
namespace
/* 未指定 */
{
inline
constexpr
/* 未指定 */
cend
=
/* 未指定 */
;
|
(C++20 起)
(定制点对象) |
|
|
调用签名
|
||
|
template
<
class
T
>
requires
/* 见下文 */
|
(C++20 起) | |
返回一个哨兵 用于常量迭代器 (自 C++23 起) ,指示 const 限定 (直至 C++23) 范围的末尾。
|
令
对
|
(C++23 前) |
|
若实参为左值或
ranges::
enable_borrowed_range
<
std::
remove_cv_t
<
T
>>
为
true
,则对
其他情况下,对
|
(C++23 起) |
如果对于表达式
e
,
ranges
::
cend
(
e
)
是有效的(其中
decltype
(
(
e
)
)
为
T
),则
CT
满足
std::ranges::range
概念,且
(C++23 前)
std::
sentinel_for
<
S, I
>
在所有情况下均为
true
,其中
S
为
decltype
(
ranges
::
cend
(
e
)
)
,
I
为
decltype
(
ranges::
cbegin
(
e
)
)
。
此外,若
S
满足
input_iterator
概念,则其同时满足
constant-iterator
概念。
(C++23 起)
定制点对象
名称
ranges::cend
表示一个
定制点对象
,它是一个常量
函数对象
,具有
字面量
类型的
semiregular
类类型。详情请参阅
定制点对象
。
示例
#include <algorithm> #include <cassert> #include <ranges> #include <vector> int main() { std::vector vec{3, 1, 4}; int arr[]{5, 10, 15}; assert(std::ranges::find(vec, 5) == std::ranges::cend(vec)); assert(std::ranges::find(arr, 5) != std::ranges::cend(arr)); }
参见
|
(C++20)
|
返回指示范围末尾的哨兵
(定制点对象) |
|
(C++11)
(C++14)
|
返回容器或数组末尾的迭代器
(函数模板) |