Namespaces
Variants
Views
Actions

std::ranges::view_interface<D>::size

From cppreference.com
 
 
Ranges library
Range access
Range conversions
(C++23)
Range primitives
Dangling iterator handling
Range concepts
Views

Factories
Adaptors
Range adaptor objects
Range adaptor closure objects
Helper items
 
std::ranges::view_interface
Member functions
(C++20)
(C++20)
size
(C++20)
(C++20)
(C++20)
(C++20)
 
constexpr auto size() requires ranges::forward_range<D> &&

    std::sized_sentinel_for<ranges::sentinel_t<D>,

                            ranges::iterator_t<D>>;
(1) (since C++20)
constexpr auto size() const requires ranges::forward_range<const D> &&

    std::sized_sentinel_for<ranges::sentinel_t<const D>,

                            ranges::iterator_t<const D>>;
(2) (since C++20)

The default implementation of size() member function obtains the size of the range by calculating the difference between the sentinel and the beginning iterator.

1) Let derived be static_cast<D&>(*this). Equivalent to return ranges::end(derived) - ranges::begin(derived);.
2) Same as (1), except that derived is static_cast<const D&>(*this).

Contents

[edit] Parameters

(none)

[edit] Return value

The difference between the sentinel and the beginning iterator of the value of the derived type.

[edit] Notes

Following derived types may use the default implementation of size():

Following types are derived from std::ranges::view_interface and do not declare their own size() member function, but they cannot use the default implementation, because their iterator and sentinel types never satisfy sized_sentinel_for:

[edit] See also

(C++17)(C++20)
returns the size of a container or array
(function template) [edit]
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]