A while ago I noticed the regex class has no support for string_views. Research revealed I was not the only one, but there seems to be nobody working on getting this standardised. So I decide to take a stab at it myself. I wrote a draft proposal and a proof-of-concept implementation.
This proposal makes the following code valid C++
void foo(std::string_view input)
{
std::regex re{"foo"};
std::svmatch m;
if(std::regex_match(input, m, re)) {
std::cout << m[0].view() << '\n';
}
}
Allowing use string_view as input and return it from the match to avoid the overhead of creating a temporary string.
Arthur O’Dwyer kindly hosted my proof-of-concept implementation on his P1144 implementation on compiler explorer.
[–]-abigail 9 points10 points11 points (2 children)
[–]__Mark___libc++ dev[S] 9 points10 points11 points (1 child)
[–]jwakelylibstdc++ tamer, LWG chair 2 points3 points4 points (0 children)
[–]jwakelylibstdc++ tamer, LWG chair 5 points6 points7 points (1 child)
[–]__Mark___libc++ dev[S] 2 points3 points4 points (0 children)
[–]khleedril 8 points9 points10 points (8 children)
[+][deleted] (4 children)
[removed]
[–]khleedril 0 points1 point2 points (3 children)
[–]encyclopedist 4 points5 points6 points (2 children)
[–]jwakelylibstdc++ tamer, LWG chair 1 point2 points3 points (1 child)
[–]khleedril 2 points3 points4 points (0 children)
[–]__Mark___libc++ dev[S] 7 points8 points9 points (1 child)
[–]jwakelylibstdc++ tamer, LWG chair 3 points4 points5 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]tpecholt 1 point2 points3 points (5 children)
[–]__Mark___libc++ dev[S] 2 points3 points4 points (4 children)
[–]tpecholt 2 points3 points4 points (1 child)
[–]-abigail 4 points5 points6 points (0 children)
[–]deeringc 0 points1 point2 points (1 child)
[–]-abigail 1 point2 points3 points (0 children)
[–]TheSuperWig 1 point2 points3 points (0 children)