Reputation: 2384
As specified in the standard:
match_prev_avail
: --first is a valid iterator position. When set, causes match_not_bol and match_not_bow to be ignored
But I run the following code and get:
#include <regex>
#include <iostream>
using namespace std;
int main()
{
regex re0("^bcd");
string str = "abcd";
std::string::iterator start = str.begin() + 1;
cout << regex_search(start, str.end(), re0, regex_constants::match_not_bol) << endl;
cout << regex_search(start, str.end(), re0, regex_constants::match_prev_avail) << endl;
cout << regex_search(start, str.end(), re0, regex_constants::match_prev_avail | regex_constants::match_not_bol) << endl;
}
output:
0
1
0
It seems that match_prev_avail
is overwritten by match_not_bol
.
Upvotes: 8
Views: 456
Reputation: 1161
Seems you found a bug in clang. (file it here: https://bugs.llvm.org/ as it seems not yet have been reported)
I checked MSVC 1914 and it gives
0
0
0
same as GCC 4.9.2 (used cpp.sh to check)
I rechecked the .pdf form of the standard (N4810) and this in 30.5.2 matches what the cppreference states.
match_prev_avail: --first is a valid iterator position. When this flag is set the flags match_not_bol and match_not_bow shall be ignored by the regular expression algorithms (30.11) and iterators (30.12)
Upvotes: 6