view: add a free contains
convenience function
This commit is contained in:
parent
4af3f5df31
commit
dbf19c5a2b
22
view.hpp
22
view.hpp
@ -1032,6 +1032,28 @@ namespace cruft {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <
|
||||
typename IteratorA,
|
||||
typename IteratorB,
|
||||
typename ValueT
|
||||
>
|
||||
requires (
|
||||
std::equality_comparable_with<
|
||||
typename std::iterator_traits<IteratorA>::value_type,
|
||||
ValueT
|
||||
>
|
||||
)
|
||||
bool
|
||||
contains (view<IteratorA, IteratorB> container, ValueT &&value)
|
||||
{
|
||||
for (auto const &inner: container)
|
||||
if (inner == value)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <
|
||||
typename BeginA, typename EndA,
|
||||
|
Loading…
Reference in New Issue
Block a user