Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::ranges...::slide_view(3) C++ Standard Libarystd::ranges...::slide_view(3)

NAME
       std::ranges::slide_view::slide_view				     -
       std::ranges::slide_view::slide_view

Synopsis
	  constexpr explicit slide_view( V base, ranges::range_difference_t<V>
       (since C++23)
	  n );

	  Constructs a slide_view initializing the underlying data members:

	    * move construct the underlying view base_ with std::move(base),
	    * the "window size"	n_ with	n.

Parameters
	  base - the source view
	  n    - the "sliding window" size

Example
       // Run this code

	#include <algorithm>
	#include <iostream>
	#include <ranges>

	int main()
	{
	    const auto source =	{1, 2, 3, 4};

	    auto slide = std::views::slide(source, 3);

	    std::ranges::for_each(slide, [](std::ranges::viewable_range	auto&&
       w)
	    {
		std::cout << '[' << w[0] << ' '	<< w[1]	<<  '  '  <<  w[2]  <<
       "]\n";
	    });
	}

Output:
	[1 2 3]
	[2 3 4]

http://cppreference.com		  2024.06.10	 std::ranges...::slide_view(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::ranges::slide_view::slide_view&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help