view: add a free contains convenience function

This commit is contained in:
Danny Robson 2022-02-17 17:01:22 +10:00
parent 4af3f5df31
commit dbf19c5a2b

View File

@ -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,