std::ranges::drop_view<V>::size
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Ranges library
(C++23)(C++23)
(C++26)(C++26)
(C++23)(C++23)
(C++26)(C++26)
(C++26)(C++26)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
constexpr auto size() requires ranges::sized_range <V>;
(1)
(since C++20)
constexpr auto size() const requires ranges::sized_range <const V>;
(2)
(since C++20)
Let base_
be the underlying view, count_
be the stored count (the number passed to the constructor, or 0 if *this is default constructed). Equivalent to
const auto s = ranges::size (base_
);
const auto c = static_cast<decltype(s)>(count_
);
return s < c ? 0 : s - c;
[edit] Return value
The number of elements.
[edit] Example
Run this code
#include <array> #include <ranges> int main() { constexpr std::array a{42, 43, 44}; static_assert ( std::ranges::drop_view {std::views::all (a), 0}.size() == 3 && std::ranges::drop_view {std::views::all (a), 1}.size() == 2 && std::ranges::drop_view {std::views::all (a), 2}.size() == 1 && std::ranges::drop_view {std::views::all (a), 3}.size() == 0 && std::ranges::drop_view {std::views::all (a), 4}.size() == 0 ); }