@@ -1940,6 +1940,28 @@ template <typename R> bool is_sorted(R &&Range) {
19401940 return std::is_sorted (adl_begin (Range), adl_end (Range));
19411941}
19421942
1943+ // / Provide wrappers to std::includes which take ranges instead of having to
1944+ // / pass begin/end explicitly.
1945+ // / This function checks if the sorted range \p R2 is a subsequence of the
1946+ // / sorted range \p R1. The ranges must be sorted in non-descending order.
1947+ template <typename R1, typename R2> bool includes (R1 &&Range1, R2 &&Range2) {
1948+ assert (is_sorted (Range1) && " Range1 must be sorted in non-descending order" );
1949+ assert (is_sorted (Range2) && " Range2 must be sorted in non-descending order" );
1950+ return std::includes (adl_begin (Range1), adl_end (Range1), adl_begin (Range2),
1951+ adl_end (Range2));
1952+ }
1953+
1954+ // / This function checks if the sorted range \p R2 is a subsequence of the
1955+ // / sorted range \p R1. The ranges must be sorted with respect to a comparator
1956+ // / \p C.
1957+ template <typename R1, typename R2, typename Compare>
1958+ bool includes (R1 &&Range1, R2 &&Range2, Compare &&C) {
1959+ assert (is_sorted (Range1, C) && " Range1 must be sorted with respect to C" );
1960+ assert (is_sorted (Range2, C) && " Range2 must be sorted with respect to C" );
1961+ return std::includes (adl_begin (Range1), adl_end (Range1), adl_begin (Range2),
1962+ adl_end (Range2), std::forward<Compare>(C));
1963+ }
1964+
19431965// / Wrapper function around std::count to count the number of times an element
19441966// / \p Element occurs in the given range \p Range.
19451967template <typename R, typename E> auto count (R &&Range, const E &Element) {
0 commit comments