std::ranges::drop_view<V>::size
Von cppreference.com
| constexpr auto size() requires ranges::sized_range<V>; |
(1) | (seit C++20) |
| constexpr auto size() const requires ranges::sized_range<const V>; |
(2) | (seit C++20) |
Sei base_ die zugrundeliegende View, count_ sei die gespeicherte Anzahl (die an den Konstruktor übergebene Anzahl oder 0, wenn *this standardkonstruiert ist). Entspricht
const auto s = ranges::size(base_);
const auto c = static_cast<decltype(s)>(count_);
return s < c ? 0 : s - c;
[edit] Rückgabewert
Die Anzahl der Elemente.
[edit] Beispiel
Führen Sie diesen Code aus
#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 ); }
[edit] Siehe auch
| (C++20) |
gibt eine Ganzzahl zurück, die der Größe eines Ranges entspricht (Customization Point Objekt) |
| (C++20) |
gibt eine vorzeichenbehaftete Ganzzahl zurück, die der Größe eines Ranges entspricht (Customization Point Objekt) |