std::ranges::borrowed_range, std::ranges::enable_borrowed_range
| Defined in header <ranges>
|
||
| template<class R> concept borrowed_range = |
(1) | |
| Defined in header <ranges>
|
||
| Defined in header <span>
|
||
| Defined in header <string_view>
|
||
| template<class R> inline constexpr bool enable_borrowed_range = false; |
(2) | |
borrowed_range defines the requirements of a range such that a function can take it by value and return iterators obtained from it without danger of dangling.enable_borrowed_range variable template is used to indicate whether a range is a borrowed_range. The primary template is defined as false.[edit] Semantic requirements
Given an expression e such that decltype((e)) is T, T models borrowed_range only if the validity of iterators obtained from the object denoted by e is not tied to the lifetime of that object.
[edit] Specializations
Specializations of enable_borrow_range for all specializations of the following standard templates are defined as true:
- std::basic_string_view
- std::span
- std::ranges::subrange
- std::ranges::ref_view
- std::ranges::empty_view
- std::ranges::iota_view
Specialization of enable_borrow_range for the following standard range adaptors are defined as true if and only if std::ranges::enable_borrowed_range<V> is true, where V is the underlying view type:
- std::ranges::take_view
- std::ranges::drop_view
- std::ranges::drop_while_view
- std::ranges::common_view
- std::ranges::reverse_view
- std::ranges::elements_view
Users may specialize enable_borrowed_range to true for cv-unqualified program-defined types which model borrowed_range, and false for types which do not. Such specializations shall be usable in constant expressions and have type const bool.

