std::basic_...w::max_size(3)
π NAME π
okay so this is the std::basic_...w::max_size(3) page from the C++ Standard Libary, and the NAME line is literally std::basic_string_view::max_size - std::basic_string_view::max_size. Bestie, it's a whole page for one tiny function and I'm obsessed. π
β¨ Synopsis β¨
constexpr size_type max_size() const noexcept;
(since C++17) β yes bestie, this one landed in C++17. The largest possible number of char-like objects that can be referred to by a basic_string_view. It's literally the max ceiling of char-like cuties a view can refer to. π
π«Ά Parameters π«Ά
(none) β literally no parameters, no stress, just vibes. π
π Return value π
Maximum number of characters. That's the whole return value, bestie. π
β‘ Complexity β‘
Constant. Periodt. β¨
π Example π
Okay, run this code:
// Run this code
#include <cstdint>
#include <iostream>
#include <limits>
#include <string_view>
int main()
{
std::cout << std::numeric_limits<std::int64_t>::max()
<< " <- numeric_limits<int64_t>::max()\n"
<< std::string_view{}.max_size()
<< " <- string_view::max_size()\n"
<< std::basic_string_view<char>{}.max_size()
<< " <- basic_string_view<char>::max_size()\n"
<< std::basic_string_view<char16_t>{}.max_size()
<< " <- basic_string_view<char16_t>::max_size()\n"
<< std::wstring_view{}.max_size()
<< " <- wstring_view::max_size()\n"
<< std::basic_string_view<char32_t>{}.max_size()
<< " <- basic_string_view<char32_t>::max_size()\n";
}
Possible output:
9223372036854775807 <- numeric_limits<int64_t>::max()
4611686018427387899 <- string_view::max_size()
4611686018427387899 <- basic_string_view<char>::max_size()
2305843009213693949 <- basic_string_view<char16_t>::max_size()
1152921504606846974 <- wstring_view::max_size()
1152921504606846974 <- basic_string_view<char32_t>::max_size()
π See also π
sizeβ returns the number of characterslengthβ (public member function)emptyβ checks whether the view is empty (public member function)max_sizeβ returns the maximum number of characters (public member function ofstd::basic_string<CharT,Traits,Allocator>)
π source/version: http://cppreference.com Β· date: 2024.06.10 Β· page: std::basic_...w::max_size(3) β bye bestie, go get that max size! π
π¦ 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