std::ranges..._view::size(3)
π NAME π
okay so welcome to the std::ranges..._view::size(3) page from the C++ Standard Libary (yes, that spelling is in the source, don't @ me π). The function bestie in the spotlight is:
std::ranges::adjacent_transform_view::size - std::ranges::adjacent_transform_view::size
Yes, it's listed twice. Iconic. Periodt. π
β¨ Synopsis β¨
This is the whole synopsis, broken line and all, bestie β copy it exactly:
constexpr auto size() requires ranges::sized_range<InnerView>;
(since C++23)
constexpr auto size() const requires ranges::sized_range<const
(since C++23)
InnerView>;
It returns the number of elements.
Let inner_ be the underlying object of type InnerView (that is the ranges::adjacent_view<V,N>).
1,2) Equivalent to return inner_.size();.
π Parameters π
(none) β literally zero parameters, bestie π«Ά
π Return value π
The number of elements, may be 0 if the size of the underlying view V is less than N.
π Example π
// Run this code
#include <ranges>
int main()
{
constexpr static auto v = {1, 2, 3, 4, 5, 6};
auto f = [](auto...) { return 0; }; // dummy
constexpr int width1 {4};
constexpr auto view1 = v |
std::views::adjacent_transform<width1>(f);
static_assert(view1.size() == 3);
static_assert(view1.size() == (v.size() - width1 + 1));
constexpr int width2 {8};
constexpr auto view2 = v |
std::views::adjacent_transform<width2>(f);
// window is too wide, so view2 has no elements:
static_assert(view2.size() == 0);
}
π¦ See also π¦
ranges::sizeβ returns an integer equal to the size of a range(C++20)(customization point object)ranges::ssizeβ returns a signed integer equal to the size of a range(C++20)(customization point object)
source/version: http://cppreference.com Β· date: 2024.06.10 β bye bestie, mwah π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms