boost::regex_search contradicts std::regex_search in changing match_result argument
- Dominant language
- C++
- Stars
- 119
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
```
#include
#include
#include
#include
std::string target("821-xxxzzz");
void st() {
std::smatch sm;
std::regex re1("^.+\\/(\\d+)$");
std::regex_search(target, sm, re1);
std::cout << "after std search, smatch is " << sm.size() << std::endl;
}
void bst() {
boost::smatch sm;
boost::regex re1("^.+\\/(\\d+)$");
boost::regex_search(target, sm, re1);
std::cout << "after boost search, smatch is " << sm.size() << std::endl;
}
int main() {
st();
bst();
return 0;
}
```
```
after std search, smatch is 0
after boost search, smatch is 2
```
STD (cppreference.com) says:
`the object match is updated as follows: If the match does not exist: match.ready() == true; match.empty() == true; match.size() == 0`
While Boost docs says:
`Postconditions: If the function returns false, then the effect on parameter match is undefined`
This assumption contradicts with the logic and expectations of end-user, that if no match was found in text, then the `boost::match_result` object state would represent it through `empty` and `size` methods. Everything said is related to `boost::regex_match` too.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.