mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
[algorithm] Add binary_search
This commit is contained in:
parent
b3a21d1173
commit
11b604f45c
@ -113,6 +113,19 @@ auto upper_bound(const span<SrcElementType, SrcExtent>& rng, const T& value, Com
|
|||||||
return details_algo::toIt(rng, ptr);
|
return details_algo::toIt(rng, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// binary_search
|
||||||
|
template <class SrcElementType, std::ptrdiff_t SrcExtent, class T>
|
||||||
|
bool binary_search(span<SrcElementType, SrcExtent> rng, const T& value)
|
||||||
|
{
|
||||||
|
return std::binary_search(rng.data(), rng.data() + rng.size(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class SrcElementType, std::ptrdiff_t SrcExtent, class T, class Compare>
|
||||||
|
bool binary_search(span<SrcElementType, SrcExtent> rng, const T& value, Compare comp)
|
||||||
|
{
|
||||||
|
return std::binary_search(rng.data(), rng.data() + rng.size(), value, comp);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace gsl
|
} // namespace gsl
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
Loading…
Reference in New Issue
Block a user