Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ranges::view_interface<D>::back

      From cppreference.com
      <cpp‎ |ranges‎ |view interface
       
       
      Ranges library
      Range adaptors
       
       
      constexpr decltype(auto) back()
          requiresranges::bidirectional_range<D>&&ranges::common_range<D>;
      (1)(since C++20)
      constexpr decltype(auto) back()const
          requiresranges::bidirectional_range<const D>&&ranges::common_range<const D>;
      (2)(since C++20)

      The default implementation ofback() member function returns the last element in the view of the derived type. Whether the element is returned by value or by reference depends on theoperator* of the iterator type.

      1) Letderived bestatic_cast<D&>(*this). Equivalent toreturn*ranges::prev(ranges::end(derived));. The behavior is undefined ifempty() istrue (i.e. the beginning iterator compares equal to the sentinel), even if the iterator obtained in the same way is dereferenceable.
      2) Same as(1), except thatderived isstatic_cast<const D&>(*this).

      Contents

      [edit]Return value

      The last element in the view.

      [edit]Notes

      In C++20, no type derived fromstd::ranges::view_interface in the standard library provides their ownback() member function.

      However, following derived types cannot use the default implementations, as they never satisfy neitherbidirectional_range norcommon_range:

      The inheritedback() member function is available forstd::ranges::empty_view, but a call to it always results in undefined behavior.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      returns a reverse iterator to the beginning of a container or array
      (function template)[edit]
      returns a reverse iterator to a range
      (customization point object)[edit]
      returns a reverse iterator to a read-only range
      (customization point object)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/view_interface/back&oldid=182210"

      [8]ページ先頭

      ©2009-2025 Movatter.jp