[regex] match_results: signatures of position(sub) and length(sub) are different, why?

Hi, On the following link, we can see that length and position member functions have different signatures: http://www.boost.org/doc/libs/1_52_0/libs/regex/doc/html/boost_regex/ref/mat... difference_type length(int sub = 0) const; difference_type position(unsigned int sub = 0) const; Why int for length(sub) and unsigned int for position(sub)? Frédéric

On the following link, we can see that length and position member functions have different signatures: http://www.boost.org/doc/libs/1_52_0/libs/regex/doc/html/boost_regex/ref/mat...
difference_type length(int sub = 0) const; difference_type position(unsigned int sub = 0) const;
Why int for length(sub) and unsigned int for position(sub)?
In fact, the documentation is wrong, but there is still an issue. This is what is in match_results.hpp: difference_type length(int sub = 0) const; difference_type position(size_type sub = 0) const; why such a difference? Frédéric

On the following link, we can see that length and position member functions have different signatures: http://www.boost.org/doc/libs/1_52_0/libs/regex/doc/html/boost_regex/ref/mat...
difference_type length(int sub = 0) const; difference_type position(unsigned int sub = 0) const;
Why int for length(sub) and unsigned int for position(sub)?
In fact, the documentation is wrong, but there is still an issue. This is what is in match_results.hpp: difference_type length(int sub = 0) const; difference_type position(size_type sub = 0) const;
why such a difference?
It's historical: length() can be used with the "special" values -1 and -2 to obtain the length of prefix() and suffix(), that's deprecated, and I don't *think* it's documented anywhere anymore, but was retained for backwards compatibility. I guess after all this time it could be changed now, but I don't see it's causing any great harm either, John.

It's historical: length() can be used with the "special" values -1 and -2 to obtain the length of prefix() and suffix(), that's deprecated, and I don't *think* it's documented anywhere anymore, but was retained for backwards compatibility.
I guess after all this time it could be changed now, but I don't see it's causing any great harm either,
Can we at least fix the documentation of position() that has the wrong signature? My issue was that position(0) was ambiguous so I tried position(0U) as I read in the doc it was an unsigned int but this worked only on win32, not in linux x86_64! Then I discovered it was a size_type in the code. I know I could use the default value (0) instead so that it would not be ambiguous with char but it looks strange to me to call position() with no number. Frédéric

It's historical: length() can be used with the "special" values -1 and -2 to obtain the length of prefix() and suffix(), that's deprecated, and I don't *think* it's documented anywhere anymore, but was retained for backwards compatibility.
I guess after all this time it could be changed now, but I don't see it's causing any great harm either,
I see that the standard says: difference_type length(size_type sub = 0) const; difference_type position(size_type sub = 0) const; Frédéric
participants (2)
-
Frédéric Bron
-
John Maddock