Skip to content

Commit d0219b6

Browse files
committed
[stlextras] Add overloads for binary_search that take containers.
1 parent 84e1d7e commit d0219b6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/swift/Basic/STLExtras.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,16 @@ inline T accumulate(const Container &C, T init, BinaryOperation op) {
638638
return std::accumulate(C.begin(), C.end(), init, op);
639639
}
640640

641+
template <typename Container, typename T>
642+
inline bool binary_search(const Container &C, T value) {
643+
return std::binary_search(C.begin(), C.end(), value);
644+
}
645+
646+
template <typename Container, typename T, typename BinaryOperation>
647+
inline bool binary_search(const Container &C, T value, BinaryOperation op) {
648+
return std::binary_search(C.begin(), C.end(), value, op);
649+
}
650+
641651
/// Returns true if the range defined by \p mainBegin ..< \p mainEnd starts with
642652
/// the same elements as the range defined by \p prefixBegin ..< \p prefixEnd.
643653
///

0 commit comments

Comments
 (0)