C++ Logo

std-proposals

Advanced search

Re: [std-proposals] regex over istreams

From: Jeremy Rifkin <rifkin.jer_at_[hidden]>
Date: Thu, 20 Feb 2025 18:48:39 -0600
Hi,

> Seems to me regex over istreams would be quite useful

Others have brought up points regarding separation of concerns, interface,
usefulness, and performance. I think this idea is a bit doomed from the
start: It seeks to combine an antiquated IO interface with an all but
deprecated(*) facet of the C++ standard library that has a lot of problems
itself.

I'd recommend looking at P1729 <http://wg21.link/P1729> which is hopefully
a modern approach we'll be moving towards.

Cheers,
Jeremy

*: std::regex has a lot of performance and API problems (e.g. no
string_view overloads), multiple widely used C++ best practices guidelines
recommend against the use of std::regex all together, and I've been told
the C++ committee isn't interested in trying to improve or fix std::regex
when they have higher priority items and high-quality third-party regex
libraries exist.


On Thu, Feb 20, 2025 at 7:48 AM Phil Bouchard via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Greetings,
>
> Seems to me regex over istreams would be quite useful. Here's an
> inefficient implementation:
>
>
> inline std::istream& operator >> (std::istream& in, std::string & v)
> {
> static const std::regex string_regex(R"(^\"(.*?)\"$)");
>
> std::smatch match;
>
> std::string x;
>
> for (x += in.get(); in; x += in.get())
> if (std::regex_match(x, match, string_regex))
> {
> v = match[1].str();
>
> return in;
> }
>
> throw std::invalid_argument("Parse error.");
> }
>
> Is there any interests in such implementation?
>
>
> Regards,
> --
> [image: Fornux Logo] <https://www.fornux.com/>
> *Phil Bouchard* [image: LinkedIn Icon]
> <https://www.linkedin.com/in/phil-bouchard-5723a910/>
> Founder & CEO
> T: (819) 328-4743
> E: phil_at_[hidden] | www.fornux.com
> 320-345 de la Gauchetière Ouest | Montréal (Qc), H2Z 0A2 Canada
> [image: The Best Predictable C++ Memory Manager]
> <https://static.fornux.com/c-superset/> Le message ci-dessus, ainsi que
> les documents l'accompagnant, sont destinés uniquement aux personnes
> identifiées et peuvent contenir des informations privilégiées,
> confidentielles ou ne pouvant être divulguées. Si vous avez reçu ce message
> par erreur, veuillez le détruire.
> This communication (and/or the attachments) is intended for named
> recipients only and may contain privileged or confidential information
> which is not to be disclosed. If you received this communication by mistake
> please destroy all copies.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2025-02-21 00:48:52