Boost logo

Boost Users :

Subject: Re: [Boost-users] [regex] match_results: signatures of position(sub) and length(sub) are different, why?
From: John Maddock (boost.regex_at_[hidden])
Date: 2012-12-12 11:40:34


> 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/match_results.html
>
> 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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net