home | help
std::ranges...w::drop_view(3)  C++ Standard Libary std::ranges...w::drop_view(3)

NAME
     std::ranges::drop_view::drop_view - std::ranges::drop_view::drop_view

Synopsis
	drop_view()  requires  std::default_initializable<V> = default;      (1)
     (since C++20)
	constexpr explicit drop_view( V  base,				     (2)
     (since C++20)
	ranges::range_difference_t<V> count );

	Constructs a drop_view.

	1)  Default  constructor. Value-initializes the underlying view and ini-
     tializes the
	count to 0. After construction, base() returns a copy of V() and  size()
     equals to
	the size of the underlying view.
	2)  Initializes  the  underlying view with std::move(base) and the count
     with count.
	After construction, base() returns a copy of base and size() returns
	ranges::size(base) - count if the size of base is not less  than  count,
     or 0
	otherwise.

Parameters
	base  - the underlying view
	count - number of elements to skip

Example
     // Run this code

      #include <algorithm>
      #include <array>
      #include <iostream>
      #include <iterator>
      #include <ranges>

      int main()
      {
	  constexpr std::array hi{'H', 'e', 'l', 'l', 'o', ',',
				  ' ', 'C', '+', '+', '2', '0'};

	  std::ranges::for_each(hi, [](const char c){ std::cout << c; });
	  std::cout << '\n';

	  constexpr  auto  n  = std::distance(hi.cbegin(), std::ranges::find(hi,
     'C'));

	  auto cxx = std::ranges::drop_view{hi, n};

	  std::ranges::for_each(cxx, [](const char c){ std::cout << c; });
	  std::cout << '\n';
      }

Output:
      Hello, C++20
      C++20

	Defect reports

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

	   DR	  Applied to		 Behavior as published		    Cor-
     rect behavior
	LWG 3714  C++20      the multi-parameter constructor was not	    made
     explicit
	(P2711R1)	     explicit

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

home | help