Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ranges::slide_view<V>::begin

      From cppreference.com
      <cpp‎ |ranges‎ |slide view
       
       
      Ranges library
      Range adaptors
       
      std::ranges::slide_view
      Member functions
      slide_view::begin
      Deduction guides
      Iterator
      Member functions
      Non-member functions
      Sentinel
      Member functions
      Non-member functions
       
      constexprauto begin()
          requires(!(/*simple-view*/<V>&&/*slide-caches-nothing*/<const V>));
      (1)(since C++23)
      constexprauto begin()const
          requires/*slide-caches-nothing*/<const V>;
      (2)(since C++23)

      Returns an iterator to the first element of theslide_view.

      1) IfV modelsslide-caches-first, equivalent to

      return iterator<false>(ranges::begin(base_),
                             ranges::next(ranges::begin(base_), n_ -1,ranges::end(base_)),
                             n_);

      Otherwise, equivalent toreturn iterator<false>(ranges::begin(base_), n_);.
      IfV modelsslide-caches-first this function caches the result within thecached_begin_ for use on subsequent calls. This is necessary to provide the amortized constant-time complexity required by therange.
      2) Equivalent toreturn iterator<true>(ranges::begin(base_), n_);.

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      Aniterator to the first element ofslide_view, which points to then_-sized subrange of the underlying view type:V for overload(1) orconst V for overload(2).

      [edit]Example

      Run this code
      #include <iostream>#include <ranges>#include <string_view>usingnamespace std::literals; int main(){staticconstexprauto source={"∀x"sv,"∃y"sv,"ε"sv,"δ"sv};auto view{std::ranges::slide_view(source,2)};constauto subrange{*(view.begin())};for(std::string_viewconst s: subrange)std::cout<< s<<' ';std::cout<<'\n';}

      Output:

      ∀x ∃y

      [edit]See also

      returns an iterator or a sentinel to the end
      (public member function)[edit]
      (C++23)
      compares a sentinel with an iterator returned fromslide_view::begin
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/slide_view/begin&oldid=181261"

      [8]ページ先頭

      ©2009-2025 Movatter.jp