e.com/w/cpp/ranges/borrowed_range) < [ std::
remove_cv_t  ](http://en.cppreference.com/w/cpp/types/remove_cv) < T  >> is
false  , or if it is of an array type of unknown bound, the call to `
ranges::end ` is ill-formed, which also results in substitution failure.

If  [ ranges::  end  ](http://en.cppreference.com/w/cpp/ranges-ranges-
placeholder/end) (  [ std::  forward
](http://en.cppreference.com/w/cpp/utility/forward) < T  > (  t  )  )  is
valid, then  decltype  (  [ ranges::  end
](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/end) (  [ std::
forward  ](http://en.cppreference.com/w/cpp/utility/forward) < T  > (  t  )  )
)  and  decltype  (  [ ranges::  begin
](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/begin) (  [ std::
forward  ](http://en.cppreference.com/w/cpp/utility/forward) < T  > (  t  )  )
)  model  [ std::sentinel_for ](/w/cpp/iterator/sentinel_for
"cpp/iterator/sentinel for") in all cases, while ` T ` models  [
std::ranges::range ](/w/cpp/ranges/range "cpp/ranges/range") .

The C++20 standard requires that if the underlying ` end ` function call
returns a prvalue, the return value is move-constructed from the materialized
temporary object. All implementations directly return the prvalue instead. The
requirement is corrected by the post-C++20 proposal [ P0849R8
](https://wg21.link/P0849R8) to match the implementations.

###  [ [ edit ](/mwiki/index.php?title=cpp/ranges/end&action=edit&section=2
"Edit section: Example") ]  Example

Run this code

    
    
    #include <algorithm>
    #include <iostream>
    #include <ranges>
    #include <vector>
     
    int main()
    {
        [std::vector](http://en.cppreference.com/w/cpp/container/vector)<int> vec{3, 1, 4};
        if (std::[ranges::find](http://en.cppreference.com/w/cpp/algorithm/ranges/find)(vec, 5) != std::[ranges::end](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/end)(vec))
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << "found a 5 in vector vec!\n";
     
        int arr[]{5, 10, 15};
        if (std::[ranges::find](http://en.cppreference.com/w/cpp/algorithm/ranges/find)(arr, 5) != std::[ranges::end](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/end)(arr))
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << "found a 5 in array arr!\n";
    }

Output:

    
    
    found a 5 in array arr!

###  [ [ edit ](/mwiki/index.php?title=cpp/ranges/end&action=edit&section=3
"Edit section: Defect reports") ]  Defect reports

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

DR  |  Applied to  |  Behavior as published  |  Correct behavior   
---|---|---|---  
[ P2602R2 ](https://wg21.link/P2602R2) |  C++20  |  there's machinery to prohibit certain non-member ` end ` found by [ ADL ](/w/cpp/language/adl "cpp/language/adl") |  removed such machinery   
  
###  [ [ edit ](/mwiki/index.php?title=cpp/ranges/end&action=edit&section=4
"Edit section: See also") ]  See also

[ ranges::cend  ](/w/cpp/ranges/cend "cpp/ranges/cend") (C++20)  |  returns a sentinel indicating the end of a read-only range   
(customization point object)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/dsc_cend&action=edit)  
---|---  
[ ranges::begin  ](/w/cpp/ranges/begin "cpp/ranges/begin") (C++20)  |  returns an iterator to the beginning of a range   
(customization point object)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/dsc_begin&action=edit)  
[ end  cend  ](/w/cpp/iterator/end "cpp/iterator/end") (C++11)  (C++14)  |  returns an iterator to the end of a container or array   
(function template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/iterator/dsc_end&action=edit)  
  
Retrieved from " [
https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/end&oldid=158239
](https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/end&o