Namespaces
Variants

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

From cppreference.net
Ranges library
Range adaptors
std::ranges::chunk_view
Member functions
chunk_view::size
Classes for input_range s
Deduction guides
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)));
}

関連項目

範囲のサイズに等しい整数を返す
(カスタマイゼーションポイントオブジェクト)
範囲のサイズに等しい符号付き整数を返す
(カスタマイゼーションポイントオブジェクト)