inel")  
[ take_while_view:: _sentinel_ :: _sentinel_
](/w/cpp/ranges/take_while_view/sentinel/sentinel "cpp/ranges/take while
view/sentinel/sentinel")  
[ take_while_view:: _sentinel_ ::base
](/w/cpp/ranges/take_while_view/sentinel/base "cpp/ranges/take while
view/sentinel/base")  
[ operator==  (take_while_view:: _sentinel_ )
](/w/cpp/ranges/take_while_view/sentinel/operator_cmp "cpp/ranges/take while
view/sentinel/operator cmp")  
  
[ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/take_while_view/navbar_content&action=edit)

Defined in header ` [ <ranges> ](/w/cpp/header/ranges "cpp/header/ranges") ` |  |   
---|---|---  
template  < [ ranges::  view  ](http://en.cppreference.com/w/cpp/ranges/view)
V,  class  Pred  >  
requires [ ranges::  input_range
](http://en.cppreference.com/w/cpp/ranges/input_range) < V  > &&  
[ std::  is_object_v  ](http://en.cppreference.com/w/cpp/types/is_object) <
Pred  > &&  
[ std::  indirect_unary_predicate
](http://en.cppreference.com/w/cpp/iterator/indirect_unary_predicate) < const
Pred, [ ranges::  iterator_t  ](http://en.cppreference.com/w/cpp/ranges-
ranges-placeholder/iterator_t) < V  >>  
class  take_while_view  
:  public  [ ranges::  view_interface  ](http://en.cppreference.com/w/cpp/ranges/view_interface) < take_while_view  < V, Pred  >> |  (1)  |  (since C++20)   
namespace  views  {  
inline  constexpr  /*unspecified*/  take_while  =  /*unspecified*/  ;  
}  |  (2)  |  (since C++20)   
Call signature  |  |   
template  < [ ranges::  viewable_range
](http://en.cppreference.com/w/cpp/ranges/viewable_range) R,  class  Pred  >  
requires  /* see below */  
constexpr  [ ranges::  view  ](http://en.cppreference.com/w/cpp/ranges/view) auto  take_while  (  R  && r, Pred  && pred  )  ;  |  |  (since C++20)   
template  < class  Pred  >  
constexpr  /*range adaptor closure*/  take_while  (  Pred  && pred  )  ;  |  |  (since C++20)   
|  |   
  
1)  A range adaptor that represents [ ` view ` ](/w/cpp/ranges/view
"cpp/ranges/view") of the elements from an underlying sequence, starting at
the beginning and ending at the first element for which the predicate returns
false.

2)  [ RangeAdaptorObject  ](/w/cpp/named_req/RangeAdaptorObject "cpp/named
req/RangeAdaptorObject") . The expression  views  ::  take_while  (  e, f  )
is [ expression-equivalent ](/w/cpp/language/expressions#Expression-
equivalence "cpp/language/expressions") to  take_while_view  (  e, f  )  for
any suitable subexpressions  e  and  f  .

take_while_view  models the concepts [ ` contiguous_range `
](/w/cpp/ranges/contiguous_range "cpp/ranges/contiguous range") , [ `
random_access_range ` ](/w/cpp/ranges/random_access_range "cpp/ranges/random
access range") , [ ` bidirectional_range ` ](/w/cpp/ranges/bidirectional_range
"cpp/ranges/bidirectional range") , [ ` forward_range `
](/w/cpp/ranges/forward_range "cpp/ranges/forward range") , and [ `
input_range ` ](/w/cpp/ranges/input_range "cpp/ranges/input range") when the
underlying view  V  models respective concepts.

##  Contents

  * 1  Member functions 
    * 1.1  Inherited from  std::ranges::view_interface 
  * 2  Deduction guides 
  * 3  Nested classes 
  * 4  Example 
  * 5  See also 

  
---  
  
###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/take_while_view&action=edit&section=1
"Edit section: Member functions") ]  Member functions

[ (constructor)  ](/w/cpp/ranges/take_while_view/take_while_view "cpp/ranges/take while view/take while view") (C++20)  |  constructs a ` take_while_view `   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/adaptor/dsc_constructor&action=edit)  
---|---  
[ base  ](/w/cpp/ranges/take_while_view/base "cpp/ranges/take while view/base") (C++20)  |  returns a copy of the underlying (adapted) view   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/adaptor/dsc_base&action=edit)  
[ pred  ](/w/cpp/r