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

FreeBSD Manual Pages

  
 
  

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

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

Synopsis
	  constexpr auto begin()

	  requires		      (!(__SimpleView<V>		    &&
       (1) (since C++20)

	  ranges::random_access_range<const V> && ranges::sized_range<const
	  V>));
	  constexpr auto begin() const
	  requires	 ranges::random_access_range<const	  V>	    &&
       (2) (since C++20)
	  ranges::sized_range<const V>;

	  Returns  an iterator to the first element of the drop_view, that is,
       an iterator to
	  the N-th element of the underlying view, or to the end of the	under-
       lying view if it
	  has less than	N elements.

	  If V is not a	random_access_range or a sized_range, in order to pro-
       vide the
	  amortized constant time complexity required by  the  range  concept,
       the overload (1)
	  caches  the result within the	drop_view object for use on subsequent
       calls.

Parameters
	  (none)

Return value
	  ranges::next(ranges::begin(base_),   count_,	  ranges::end(base_)),
       where base_ is the
	  underlying view, and count_ is the number of elements	to skip.

Example
       // Run this code

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

	int main()
	{
	    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';

	    const  auto	 c  =  std::distance(hi.begin(), std::ranges::find(hi,
       'C'));
	    auto cxx = std::ranges::drop_view{ hi, c };
	    std::cout << "*drop_view::begin() == '" << *cxx.begin() << "'\n";

	//  *cxx.begin() = 'c';	// undefined: 'views' are to be	 used  as  ob-
       servers

	    for	(char c	: cxx) { std::cout << c; }
	    std::cout << '\n';
	}

Output:
	Hello, C++20!
	*drop_view::begin() == 'C'
	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 3482 C++20      the const	overload can be	called	    the	 const
       overload	requires
			      with unsized ranges		   sized_range

See also
	  end		returns	an iterator or a sentinel to the end
	  (C++20)	(public	member function)
	  ranges::begin	returns	an iterator to the beginning of	a range
	  (C++20)	(customization point object)
	  ranges::end	returns	a sentinel indicating the end of a range
	  (C++20)	(customization point object)

http://cppreference.com		  2022.07.31	 std::ranges..._view::begin(3)

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

home | help