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

FreeBSD Manual Pages

  
 
  

home | help
std::ranges..._view::pred(3)  C++ Standard Libary std::ranges..._view::pred(3)

NAME
       std::ranges::drop_while_view::pred - std::ranges::drop_while_view::pred

Synopsis
	  constexpr const Pred&	pred() const;  (since C++20)

	  Returns a reference to the stored predicate.

	  If  *this does not store a predicate (e.g. an	exception is thrown on
       the assignment
	  to *this, which copy-constructs or move-constructs a Pred), the  be-
       havior is
	  undefined.

Parameters
	  (none)

Return value
	  a reference to the stored predicate

Example
       // Run this code

	#include <array>
	#include <iostream>
	#include <iomanip>
	#include <ranges>

	int main()
	{
	    constexpr std::array data{ 0, -1, -2, 3, 1,	4, 1, 5, };

	    auto view =	std::ranges::drop_while_view{
		data, [](int x)	{ return x <= 0; }
	    };

	    std::cout << std::boolalpha;
	    for	(int x:	data) {
		std::cout << "predicate(" << std::setw(2) << x << ") : "
			  << view.pred()(x) << '\n';
	    }
	}

Output:
	predicate( 0) :	true
	predicate(-1) :	true
	predicate(-2) :	true
	predicate( 3) :	false
	predicate( 1) :	false
	predicate( 4) :	false
	predicate( 1) :	false
	predicate( 5) :	false

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

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

home | help