std::ranges...erface::size(3)
β¨ std::ranges::view_interface::size β¨
okay bestie, this is the C++ Standard Libary manual page for std::ranges::view_interface::size, and weβre gonna make it make sense. no cap. π«Ά
π NAME π
std::ranges::view_interface::size β std::ranges::view_interface::size
πΈ Synopsis πΈ
hereβs the exact signature energy, bestie β two overloads, both (since C++20), and yes the formatting is giving βmanpage chicβ ππ
constexpr auto size() requires ranges::forward_range<D> &&
std::sized_sentinel_for<ranges::sentinel_t<D>,
(1) (since C++20)
ranges::iterator_t<D>>;
constexpr auto size() const requires ranges::forward_range<const
D> &&
(2)
(since C++20)
std::sized_sentinel_for<ranges::sentinel_t<const D>,
ranges::iterator_t<const D>>;
the default implementation of the size() member function gets the size of the range by calculating the difference between the sentinel and the beginning iterator. iconic behavior, honestly. β¨
- let
derivedbestatic_cast<D&>(*this). Equivalent toreturn /*to-unsigned-like*/(ranges::end(derived) - ranges::begin(derived));, where the exposition-only function templateto-unsigned-likeperforms the explicit cast from the argument type to its corresponding unsigned type. - same as (1), except that
derivedisstatic_cast<const D&>(*this).
π«Ά Parameters π«Ά
(none) β literally none. no args, no stress. π
π Return value π
the difference between the sentinel and the beginning iterator of the value of the derived type, converted to its corresponding unsigned type. slay. π
π§ Notes π§
following derived types may use the default implementation of size():
std::ranges::drop_while_view
following types are derived from std::ranges::view_interface and do not declare their own size() member function, but they cannot use the default implementation, because their iterator and sentinel types never satisfy sized_sentinel_for:
std::ranges::basic_istream_viewstd::ranges::filter_viewstd::ranges::join_viewstd::ranges::lazy_split_viewstd::ranges::split_viewstd::ranges::take_while_view
π Defect reports π
the following behavior-changing defect reports were applied retroactively to previously published C++ standards:
- LWG 3646 β applied to C++20; as published: the default implementations of
sizefunctions returned a signed type; correct behavior: they return unsigned type.
π₯ See also π₯
size(C++17) β returns the size of a container or array (function template)ssize(C++20) β returns the size of a container or array (function template)ranges::size(C++20) β returns an integer equal to the size of a range (customization point object)ranges::ssize(C++20) β returns a signed integer equal to the size of a range (customization point object)
source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::ranges...erface::size(3) β bye bestie, go get that unsigned type π
β¨
π¦ 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