Visual Computing Library
Loading...
Searching...
No Matches
vcl::RangeOf Concept Reference

Utility concept that is evaluated true the Range R has a value_type that is exactly T. More...

#include <vclib/concepts/ranges/range.h>

Concept definition

template<typename R, typename T>
concept vcl::RangeOf = Range<R> && std::same_as<std::ranges::range_value_t<R>, T>
Utility concept that is evaluated true the Range R has a value_type that is exactly T.
Definition range.h:66
Utility concept that is evaluated true if T is a range, e.g. if has a begin and an end.
Definition range.h:39

Detailed Description

Utility concept that is evaluated true the Range R has a value_type that is exactly T.

This concept is useful when you need to check that a range has a value_type that is exactly T, and not convertible to T. When this concept is satisfied the following code will always compile:

for (const T& value : range) {
// do something with value
...
}
Note
If the type of the range is not T, this concept will be evaluated false, even if it is convertible to T. If you need to check that the range has a value_type that is convertible to T, use the InputRange concept.
Template Parameters
RThe range type.
TThe value type.