Talk:cpp/regex/match results/empty

May I suggest to add a note whether it is legal or UB to access (or ) if the reglar expression to which the  was an argument didn't match?

I found this as a minor difference between the C++ standard library implementation on Linux and Boost.Regex. The same code linked with the regular expression implementation in the Linux C++ standard has no problem with that access but the boost implementation throws

what: Attempt to access an uninitialzed boost::match_results<> class.

I'm aware this is a bit Linux/Boost specific and a border-case topic for a C++ site, but it makes sense in so far as the Linux C++ standard library had a broken implementation of regular expressions for a long time. Therefore Linux developers with not quite recent versions will still have to use Boost.Regex as a drop-in replacement - usually not a big problem switching via namespace alias, except such small nuisances.

And of course, it might still be the case that accessing an object after an unsuccessful attempt to match is UB and my program worked just out of luck, i.e. Boost.Regex was right to be a bit more picky.

Mwe (talk) 07:50, 7 March 2016 (PST)
 * It's legal. is equivalent to, and  is required to return "One plus the number of marked sub-expressions in the regular expression that was matched if  represents the result of a successful match. Otherwise returns ." That is, if  does not represent the result of a successful match,  shall return  and  shall return . --D41D8CD98F (talk) 08:59, 7 March 2016 (PST)