std::ranges::cend

Header: <ranges>

Returns a sentinelfor the constant iterator(since C++23) indicating the end of a const-qualified(until C++23) range.

# Declarations

inline namespace /* unspecified */ {
inline constexpr /* unspecified */ cend = /* unspecified */;
}

(since C++20) (customization point object)

Call signature
template< class T >
requires /* see below */
constexpr /* see below */ auto cend( T&& t );

(since C++20)

# Example

#include <algorithm>
#include <cassert>
#include <ranges>
#include <vector>
 
int main()
{
    std::vector vec{3, 1, 4};
    int arr[]{5, 10, 15};
 
    assert(std::ranges::find(vec, 5) == std::ranges::cend(vec));
    assert(std::ranges::find(arr, 5) != std::ranges::cend(arr));
}

# See also