On 04/18/2017 02:48 AM, Jethro wrote:
I generally need this for regex stuff and it's quite annoying it doesn't
work.

if (!match(s, "\s*(?P<t>.),").empty())
{
// Need the result of match to do things!
}

but this doesn't work:


if (!(auto r = match(s, "\s*(?P<t>.),")).empty())
{

}

Stanislav Blinov has shown how overloading `cast(bool)` can help here. In fact, std.regex.RegexMatch does just that. So this works:

----
if (auto r = match(s, "\s*(?P<t>.),"))
{
    /* ... use r here ... */
}
----

Reply via email to