Index: include/llvm/ADT/STLExtras.h =================================================================== --- include/llvm/ADT/STLExtras.h +++ include/llvm/ADT/STLExtras.h @@ -1300,6 +1300,19 @@ -> decltype(adl_begin(Range)) { return std::upper_bound(adl_begin(Range), adl_end(Range), I, C); } + +/// Provide wrappers to std::binary_search which take ranges instead of having +/// to pass begin/end explicitly. +template +bool binary_search(R &&Range, const E &Element) { + return std::binary_search(adl_begin(Range), adl_end(Range), Element); +} + +template +bool binary_search(R &&Range, const E &Element, Compare C) { + return std::binary_search(adl_begin(Range), adl_end(Range), Element, C); +} + /// Wrapper function around std::equal to detect if all elements /// in a container are same. template