C++ Logo

std-proposals

Advanced search

[RFC] String_view support for regex

From: Mark de Wever <koraq_at_[hidden]>
Date: Tue, 17 Sep 2019 19:44:25 +0200
Hi,

I've posted before about this proposal and based on the feedback here
and on Reddit I've improved my proposal. I've also updated the wording
to the latest draft N4830.

The proposal adds string_view support to various parts of regex. Its
main goal was to make the following code valid:

void foo(std::string_view input) {
    std::regex re{"foo.*bar"};
    std::svmatch match;
    if (regex_match(input, match, re)) {
        std::cout << "Found " << match[0] << "\n";
        std::string_view sv = match[0].view();
        
        // Do stuff with sv
    }
}

Attached the latest draft. Any more suggestions how to improve this
paper?

(Note haven't asked Arthur to update the Compiler Explorer branch to the
lastest version yet.)

Kind regards,
Mark de Wever

Received on 2019-09-17 12:46:38