Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ranges::view_interface<D>::front

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

      The default implementation offront() member function returns the first 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::begin(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 first element in the view.

      [edit]Notes

      In C++20, no type derived fromstd::ranges::view_interface in the standard library provides their ownfront() member function. Almost all of these types use the default implementation.

      A notable exception isstd::ranges::basic_istream_view. For it never satisfiesforward_range, the view cannot use the inheritedfront().

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

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

      [8]ページ先頭

      ©2009-2025 Movatter.jp