// Helper to sanitize a word to lowercase alphanumeric charactersHere, it seems the variable /clean/ is completely superfluous [1].
auto sanitize = [](std::string w) {
auto clean = w | std::views::filter([](char c) { return std::isalnum(c); })
| std::views::transform([](char c) { return std::tolower(c); });
return std::string(clean.begin(), clean.end());
};
// Helper to sanitize a word to lowercase alphanumeric charactersDear Stefan,
auto sanitize = [](std::string w) {
auto clean = w | std::views::filter([](char c) { return std::isalnum(c); })
| std::views::transform([](char c) { return std::tolower(c); });
return std::string(clean.begin(), clean.end());
};
On 8/27/2026 6:47 PM, Stefan Ram wrote:
Has Bjarne thought to include PCRE2 in C++ already?ÿ Can we use a reg-
ular expression to match ' only if it's inside a word?ÿ Do we want to
account for Unicode single curly quotes too?
C++ has had a regex library since C++11.
"Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> wrote or quoted:
Has Bjarne thought to include PCRE2 in C++ already? Can we use a reg-
ular expression to match ' only if it's inside a word? Do we want to
account for Unicode single curly quotes too?
"::std::regex" was introduced in C++11 (2011), but due to
performance problems, it's scheduled to be deprecated.
Newsgroups: comp.lang.misc,comp.lang.c++
Has Bjarne thought to include PCRE2 in C++ already? Can we use a reg-
ular expression to match ' only if it's inside a word? Do we want to
account for Unicode single curly quotes too?
On Fri, 18 Sep 2026 11:05:46 +0800
"Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> gabbled:
Has Bjarne thought to include PCRE2 in C++ already?ÿ Can we use a reg-
ular expression to match ' only if it's inside a word?ÿ Do we want to
account for Unicode single curly quotes too?
Instead of ever niche academic circle jerking wrt C++ expansion, it
would be
nice if some more basic stuff was added first that other languages have supported since their inception. Eg, how about a switch() construct that operated on more than just POD types?
std::string mystr = "hello";
:
:
switch(mystr)
{
case "hello": ...
case "world": ...
:
}
etc.
So long as the object had operator==() defined I see no problem with overloading
switch in this way.
The amount of times I've had to write endless if-else's instead of this
I've
lost count of.
boltar@caprica.universe writes: Eg, how about a switch() construct that >>operated on more than just POD types?
Expected in C++29:
inspect (mystr) {
"hello" => { /* ... */ },
"world" => { /* ... */ },
_ => { /* default */ }
};
On 18 Sep 2026 15:25:17 GMT
ram@zedat.fu-berlin.de (Stefan Ram) gabbled:
boltar@caprica.universe writes: Eg, how about a switch() construct that >>> operated on more than just POD types?
Expected in C++29:
inspect (mystr) {
"hello" => { /* ... */ },
"world" => { /* ... */ },
_ => { /* default */ }
};
Wtf?? Why an entirely new construct, just overload switch! Also I can guarantee than there's a ton of current code that will already be using the word "inspect" in some way.
On 18/09/2026 17:49, boltar@caprica.universe wrote:
On 18 Sep 2026 15:25:17 GMT
ram@zedat.fu-berlin.de (Stefan Ram) gabbled:
boltar@caprica.universe writes:ÿÿ Eg, how about a switch() construct
that
operated on more than just POD types?
ÿ Expected in C++29:
inspect (mystr) {
ÿÿÿ "hello" => { /* ... */ },
ÿÿÿ "world" => { /* ... */ },
ÿÿÿ _ÿÿÿÿÿÿ => { /* default */ }
};
Wtf?? Why an entirely new construct, just overload switch! Also I can
guarantee than there's a ton of current code that will already be
using the
word "inspect" in some way.
"inspect" is /not/ expected in C++29 - Stefan is a bit out of date.ÿ It
was one of several alternative proposals for a new pattern-matching
feature.ÿ The current candidate is "match", with a syntax like :
ÿÿÿÿx match {
ÿÿÿÿÿÿÿ 0 => std::printf("zero");
ÿÿÿÿÿÿÿ 1 => std::printf("one");
ÿÿÿÿÿÿÿ _ => std::printf("something else");
ÿÿÿÿ}
This works like a normal "switch", but there is no fall-through (so no "break" statements), and it is not weirdly unstructured.
ÿÿÿÿs match {
ÿÿÿÿÿÿÿ "zero" => std::printf("zero");
ÿÿÿÿÿÿÿ "one" => std::printf("one");
ÿÿÿÿÿÿÿ _ => std::printf("something else");
ÿÿÿÿ}
It will work with any literal types.ÿ It can also be used to match
variant types, polymorphic types, etc.
And there are few situations where an existing identifier "match" could
be in conflict with the new keyword.ÿ (You could cause trouble with a
macro called "match", but that seems unlikely in real code.)
boltar@caprica.universe wrote or quoted:
Why an entirely new construct, just overload switch!
Switch already has fall-through semantic which is not desired
for the new inspect statement. Also parsing both the old and
the new "case" syntax can become difficult.
Also I can guarantee than there's a ton of current code that
will already be using the word "inspect" in some way.
If the compiler sees "inspect (variable) { ... }", it parses
it as a pattern-matching block.
If it sees "int inspect = 5;" or "my_object.inspect()", it treats
it as a completely valid standard identifier.
On 18 Sep 2026 16:05:52 GMT
ram@zedat.fu-berlin.de (Stefan Ram) gabbled:
boltar@caprica.universe wrote or quoted:
Why an entirely new construct, just overload switch!
Switch already has fall-through semantic which is not desired
for the new inspect statement. Also parsing both the old and
Says who?
the new "case" syntax can become difficult.
Rubbish. Other languages manage.
Also I can guarantee than there's a ton of current code that
will already be using the word "inspect" in some way.
If the compiler sees "inspect (variable) { ... }", it parses
it as a pattern-matching block.
If it sees "int inspect = 5;" or "my_object.inspect()", it treats
it as a completely valid standard identifier.
So we treat "inspect" differently to every other keyword in that it can be used as a variable/function/whatever name too? Well that won't be confusing at all!
| Sysop: | Tetrazocine |
|---|---|
| Location: | Melbourne, VIC, Australia |
| Users: | 8 |
| Nodes: | 8 (0 / 8) |
| Uptime: | 190:50:16 |
| Calls: | 221 |
| Files: | 21,513 |
| Messages: | 85,755 |