According to the C++17 Standard:
28.10 Class template match_results
[ re.results
]
4 The sub_match object stored at index 0 represents sub-expression 0, i.e., the whole match. In this case the sub_match member matched is always true. The sub_match object stored at index n denotes what matched the marked sub-expression n within the matched expression. If the sub-expression n participated in a regular expression match then the sub_match member matched evaluates to true, and members first and second denote the range of characters [first,second) which formed that match. Otherwise matched is false, and members first and second point to the end of the sequence that was searched.
[ Note: The sub_match objects representing different sub-expressions that did not participate in a regular expression match need not be distinct. — end note ]
Now m.position(n)
returns (*this)[n].first
.
Given that "[If] matched is false, [then] members first and second point to the end of the sequence that was searched" ...
This means m.position(n)
should point "to the end of the sequence that was searched".