std::ranges...m_view::size(3)
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
- 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