You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The algorithm locates sequence 2 within sequence 1. In other words, it returns the first iterator i in sequence 1 such that for each non-negative integer n, *(=i + n) equals (ipt_begin2 + n), or if you provide a predicate pred((i + n), *(ipt_begin2 + n)) is true. The search algorithm returns ipt_begin1 if sequence 2 is empty or ipt_begin2 if no subsequence is found. This is different from find because it locates a subsequence rather than a single element.
(1) Notice that the variables "ipt_begin1" and "ipt_begin2" are different from what's actually used in the function declaration given later, which instead uses "fwd_" variants of the names.
(2) Most importantly, the phrase "or ipt_begin2 if no subsequence is found" appears to be wrong and misleading. The test case code shows that it appears to actually return an end iterator (which is far more reasonable), not a begin iterator. This was very confusing when I first read it. I'm sure it will confuse others too.
In contrast though, returning a begin iterator for searching for an empty subseq makes sense, since an empty subsequence is a subsequence of any sequence, but that's a different case.
Consider a general rewrite of the paragraph in general too, perhaps.
The text was updated successfully, but these errors were encountered:
In this text from the page:
ForwardIterator search([ ep], fwd_begin1, fwd_end1, fwd_begin2, fwd_end2, [pred]);
There are two main problems here:
(1) Notice that the variables "ipt_begin1" and "ipt_begin2" are different from what's actually used in the function declaration given later, which instead uses "fwd_" variants of the names.
(2) Most importantly, the phrase "or ipt_begin2 if no subsequence is found" appears to be wrong and misleading. The test case code shows that it appears to actually return an end iterator (which is far more reasonable), not a begin iterator. This was very confusing when I first read it. I'm sure it will confuse others too.
In contrast though, returning a begin iterator for searching for an empty subseq makes sense, since an empty subsequence is a subsequence of any sequence, but that's a different case.
Consider a general rewrite of the paragraph in general too, perhaps.
The text was updated successfully, but these errors were encountered: