Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ranges::view_interface<D>::size

      From cppreference.com
      <cpp‎ |ranges‎ |view interface
       
       
      Ranges library
      Range adaptors
       
       
      constexprauto size() requiresranges::forward_range<D>&&

         std::sized_sentinel_for<ranges::sentinel_t<D>,

                                 ranges::iterator_t<D>>;
      (1)(since C++20)
      constexprauto size()const requiresranges::forward_range<const D>&&

         std::sized_sentinel_for<ranges::sentinel_t<const D>,

                                 ranges::iterator_t<const D>>;
      (2)(since C++20)

      The default implementation ofsize() member function obtains the size of the range by calculating the difference between the sentinel and the beginning iterator.

      Contents

      [edit]Return value

      1)to-unsigned-like (ranges::end(static_cast<D&>(this))-
                           ranges::begin(static_cast<D&>(this)))
      .
      2)to-unsigned-like (ranges::end(static_cast<const D&>(this))-
                           ranges::begin(static_cast<const D&>(this)))
      .

      [edit]Notes

      Following derived types may use the default implementation ofsize():

      Following types are derived fromstd::ranges::view_interface and do not declare their ownsize() member function, but they cannot use the default implementation, because their iterator and sentinel types never satisfysized_sentinel_for:

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 3646C++20the default implementations ofsize functions returned a signed typethey return unsigned type

      [edit]See also

      (C++17)(C++20)
      returns the size of a container or array
      (function template)[edit]
      returns an integer equal to the size of a range
      (customization point object)[edit]
      returns a signed integer equal to the size of a range
      (customization point object)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/view_interface/size&oldid=176014"

      [8]ページ先頭

      ©2009-2025 Movatter.jp