Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::basic_string_view<CharT,Traits>::max_size

      From cppreference.com
      <cpp‎ |string‎ |basic string view
       
       
       
      std::basic_string_view
       
      constexpr size_type max_size()constnoexcept;
      (since C++17)

      The largest possible number of char-like objects that can be referred to by abasic_string_view.

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      Maximum number of characters.

      [edit]Complexity

      Constant.

      [edit]Example

      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()

      [edit]See also

      returns the number of characters
      (public member function)[edit]
      checks whether the view is empty
      (public member function)[edit]
      returns the maximum number of characters
      (public member function ofstd::basic_string<CharT,Traits,Allocator>)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/string/basic_string_view/max_size&oldid=167616"

      [8]ページ先頭

      ©2009-2025 Movatter.jp