#ifndef SPROUT_ALGORITHM_BINARY_SEARCH_HPP #define SPROUT_ALGORITHM_BINARY_SEARCH_HPP #include #include #include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace detail { template inline SPROUT_CONSTEXPR bool binary_search_impl(ForwardIterator first, ForwardIterator last, T const& value, Compare comp) { return (first != last && !comp(value, *first)); } } // namespace detail // 25.4.3.4 binary_search // // recursion depth: // O(log N) // template inline SPROUT_CONSTEXPR bool binary_search(ForwardIterator first, ForwardIterator last, T const& value, Compare comp) { return sprout::detail::binary_search_impl(sprout::lower_bound(first, last, value), last, value, comp); } template inline SPROUT_CONSTEXPR bool binary_search(ForwardIterator first, ForwardIterator last, T const& value) { return sprout::binary_search( first, last, value, NS_SSCRISK_CEL_OR_SPROUT::less::value_type>() ); } } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_BINARY_SEARCH_HPP