std::ranges::constant_range
From cppreference.com
 
 
 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Ranges library 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
(C++23)(C++23)
  (C++26)(C++26)
(C++23)(C++23)
  (C++26)(C++26)
(C++26)(C++26)
  (C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
  (C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
Defined in header 
 
 
<ranges> 
 template< class T >
 (1) 
 (since C++23) 
concept constant_range =
    ranges::input_range <T> &&
Helper concepts
 
 
template< class T >
 (2)
 (exposition only*)
concept /*constant-iterator*/ =
    std::input_iterator <T> &&
1) The 
constant_range concept is a refinement of range for which ranges::begin returns a constant iterator.2) The concept /*constant-iterator*/<T> is satisfied when the result of the indirection operation of the input iterator is its const reference type which implies read-only.
[edit] Example
Run this code
#include <ranges> #include <span> #include <string_view> #include <vector> // mechanisms for ensuring the parameter is a constant range // 1) an overload set where the mutable one defers to the constant one template<std::ranges::constant_range R> void takes_any_range1(R&& r) { // R is definitely a constant range } template<std::ranges::range R> void takes_any_range1(R&& r) { takes_any_range1(std::views::as_const (std::forward <R>(r))); } // 2) one function template that shadows its parameter template<std::ranges::range R> void takes_any_range2(R&& _r) { auto r = std::views::as_const (std::forward <R>(_r)); // r is definitely a constant range // never use _r again } // 3) one function template that recursively invokes itself template<std::ranges::range R> void takes_any_range3(R&& r) { if constexpr (std::ranges::constant_range<R>) { // R is definitely a constant range // put implementation here } else takes_any_range3(std::views::as_const (std::forward <R>(r))); } static_assert ( std::ranges::constant_range<const std::vector <int>> and not std::ranges::constant_range<std::vector <int>> and std::ranges::constant_range<std::string_view > and not std::ranges::constant_range<std::span <int>> and std::ranges::constant_range<std::span <const int>> and not std::ranges::constant_range<const std::span <int>> ); int main() {}