std::match_results::empty(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

okay so bestie, welcome to std::match_results::empty(3) from the C++ Standard Libary β€” yes, that’s the manual name in the header, spelling and all, and we are not touching it. This one is short and iconic: it’s basically the vibe check for whether a match actually matched. ✨

🌸 NAME 🌸

std::match_results::empty β€” std::match_results::empty (the name said it twice, and honestly? slay.)

✨ Synopsis ✨

          bool empty() const;                (since C++11)
                                             (until C++20)
          [[nodiscard]] bool empty() const;  (since C++20)

Checks whether the match was successful. That’s the whole assignment, no cap. 🎯

πŸŽ€ Parameters πŸŽ€

(none) β€” literally zero parameters, not even a tiny one. πŸ’…

πŸ’– Return value πŸ’–

It gives you true if *this represents the result of a failed match, and false otherwise, i.e. size() == 0. So yes: failed-match energy gets true, and everything else gets false. 😭

😭 Exceptions 😭

May throw implementation-defined exceptions. So like, it’s not contractually chill 100% of the time β€” the implementation gets to define its own chaos. πŸ™ˆ

⚑ Complexity ⚑

Constant. That’s it. No dramatic runtime arc. πŸ’€

πŸ‘€ See also πŸ‘€

  • size β€” returns the number of matches in a fully-established result state (public member function).

xoxo, your source is http://cppreference.com, dated 2024.06.10 β€” mwah πŸ’‹

πŸ“¦ where this page comes from