std::ranges...m_view::size(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

hey bestie πŸ’– welcome to the C++ Standard Libary manual page for std::ranges...m_view::size(3) β€” yes, that’s the title, and yes, the manual name really is C++ Standard Libary. buckle up πŸŽ€

✨ NAME ✨

std::ranges::transform_view::size β€” std::ranges::transform_view::size

πŸ¦‹ Synopsis πŸ¦‹

okay so here’s the signature tea β˜•:

constexpr auto size() requires ranges::sized_range<V>;
(since C++20)
constexpr auto size() const requires ranges::sized_range<const V>;
(since C++20)

So what does it do? It returns the number of elements. literally that. πŸ’… And it gets there by returning ranges::size(base_), where base_ is the underlying view. slay.

🌸 Parameters 🌸

(none) β€” not a single one, bestie. 🫢

πŸ’– Return value πŸ’–

The number of elements. that’s the whole mood. ✨

⭐ Notes ⭐

If V does not model forward_range, size() might not be well-defined after a call to begin(). so like… be aware, no cap. 😭

πŸŽ€ Example πŸŽ€

run this code, bestie:

// Run this code

#include <cctype>
#include <iostream>
#include <ranges>
#include <string>

int main()
{
    std::string s{"The length of this string is 42 characters"};
    auto tv = std::ranges::transform_view{s, [](char c) -> char
    {
        return std::toupper(c);
    }};
    for (auto x : tv)
        std::cout << x;
    std::cout << "\nsize = " << tv.size() << '\n';
}

🌈 Output 🌈

THE LENGTH OF THIS STRING IS 42 CHARACTERS
size = 42

πŸ‘‘ 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) πŸ’…

that’s the page, bestie 🫢 source/version + date tea: http://cppreference.com, 2024.06.10, and the page itself is std::ranges...m_view::size(3). bye πŸ’–

πŸ“¦ where this page comes from