std::ranges::chunk_view::size - cppreference.com (original) (raw)

Returns the number of elements, which is the smallest integer value that is not less than the quotient of dividing the size of underlying view _[base](../chunk%5Fview.html#base "cpp/ranges/chunk view")_ by the underlying data member _[n](../chunk%5Fview.html#n "cpp/ranges/chunk view")_, that holds the number passed to the constructor (​0​ if default constructed). Equivalent to return _to-unsigned-like_(_[div-ceil](../chunk%5Fview.html#div-ceil "cpp/ranges/chunk view")_(ranges::distance(_[base](../chunk%5Fview.html#base "cpp/ranges/chunk view")_), _[n](../chunk%5Fview.html#n "cpp/ranges/chunk view")_)); .

[edit] Return value

The number of elements.

[edit] Example

#include   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))); }

[edit] See also

| | returns an integer equal to the size of a range(customization point object)[edit] | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | | returns a signed integer equal to the size of a range(customization point object)[edit] |