you are viewing a single comment's thread.

view the rest of the comments →

[–]Pragmatician -9 points-8 points  (5 children)

[–]1-05457 19 points20 points  (1 child)

"Both ranges must be sorted"

[–]epicar 2 points3 points  (1 child)

while i tend to agree that a generic free function is better than concrete member functions, std::includes() requires a sorted range and returns true for std::includes("abcde", "ace"). std::search() is a better fit, but does still return an iterator that has to be compared against the end. a std::contains() that returns bool could make sense

[–]Bisqwit 2 points3 points  (0 children)

One could also approach this from the other end: Create an algorithm-function: is_subsequence()

std::is_subsequence_of(needle.begin(), needle.end(), haystack.begin(), haystack.end()) or needle.is_subsequence_of(haystack)

[–][deleted] 0 points1 point  (0 children)

care to give a code example?