Possible typo for set_intersection

All,

I'm new to the forum but a long-time viewer of cplusplus.com. I was using it as a reference lately and stumbled upon the following sentence on the std::set_intersection page for the result of the function call:

result
Output iterator to the initial position of the range where the resulting sequence is stored.
The pointed type shall support being assigned the value of an element from the first range.


It didn't make sense that the iterator should return to the beginning of the range that was constructed from the intersection. The pseudocode listed as "equivalent behavior" shows the result being incremented each time an entry is added to the set intersection. Therefore it should return the (one-past-the) end of the range.

Also, in the code snippet at the bottom of the page the returned iterator is used to resize the vector to the appropriate size. If the returned iterator was the beginning of the range then the output of the code would be nothing since the resize would remove everything.

Maybe I'm misunderstanding the phrasing of the above quoted text, but it appears wrong.
Yes. It is clearly a mistake.
Use a Spotted an error? contact us button (on the bottom of the page, below copyright information) while on problem page and describe problem here.
Done, thanks.
All,

I received an email from Juan Soulie with the following text:

Hello, *****,
I've been reading the page you link, and although it contains a rather terse description that could definitely be improved, I can't seen to find the error or typo. As I see it, what you pass as fifth argument is the beginning of the range, and what gets returned by the function is its end. The iterator passed as argument is never actually modified by the function (but a copy).
Please, let me know if I missed something.
In any case, thanks for reporting this issue. All feedback is appreciated.
Best regards,


And I responded with:

Juan,

From your email:
"As I see it, what you pass as fifth argument is the beginning of the range, and what gets returned by the function is its end. The iterator passed as argument is never actually modified by the function (but a copy)."

I agree, this is the behavior of the function/API. However, the text on that page says that the return value is the *initial* position of the returned range and should say it is the *final* or *one past the end* of the range. I apologize that I did not make myself clear. The typo is in the text description of the return value not the coded example, or equivalent code.

Yours,


I have not received any further correspondence (over 48hours) and the page is still incorrect as of right now. Is there anything else I can do or should I consider my work done?
From my look at the page, it looks to be completely correct. You pass an iterator (pointer) to the point in memory where it should start storing the result for the intersection. The return value, however, is something else again - it is the iterator to the end of the values modified by the intersection. It does say that the return value is the end of the range.
NT3,

Hmmm you're right. I guess I'm going crazy.
Topic archived. No new replies allowed.