std::ranges::chunk_view<V>:: size
|
||||||||||||||||||||||
| Range primitives | |||||||
|
|||||||
| Range concepts | |||||||||||||||||||
|
|||||||||||||||||||
| Range factories | |||||||||
|
|||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||
| Helper items | |||||||||||||||||
|
|
||||||||||||||||
| Member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
chunk_view::size
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
(C++26)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
constexpr
auto
size
(
)
requires
ranges::
sized_range
<
V
>
;
|
(1) | (自 C++23 起) |
|
constexpr
auto
size
(
)
const
requires
ranges::
sized_range
<
const
V
>
;
|
(2) | (自 C++23 起) |
返回元素数量,即不小于底层视图
base_
的大小除以底层数据成员
n_
(保存传递给构造函数的数值,若默认构造则为
0
)所得商的最小整数值。等价于
return
to-unsigned-like
(
div-ceil
(
ranges::
distance
(
base_
)
,
n_
)
)
;
。
返回值
元素数量。
示例
#include <ranges> int main() { constexpr static auto v = {1, 2, 3, 4, 5}; constexpr auto w{ std::ranges::chunk_view(v, 2) }; static_assert(w.size() == (5 / 2 + (5 % 2 ? 1 : 0))); }
参见
|
(C++20)
|
返回等于范围大小的整数值
(定制点对象) |
|
(C++20)
|
返回等于范围大小的有符号整数值
(定制点对象) |