名稱空間
變體
操作

std::ranges::chunk_view<V>::size

來自 cppreference.com
< cpp‎ | ranges‎ | chunk view
 
 
範圍庫 (Ranges library)
範圍介面卡 (Range adaptors)
 
std::ranges::chunk_view
成員函式
chunk_view::size
input_range 的類
推導指引
outer-iterator
outer-iterator::value_type
inner-iterator
 
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)));
}

[編輯] 參閱

返回等於範圍大小的整數
(定製點物件)[編輯]
返回等於範圍大小的有符號整數
(定製點物件)[編輯]