std::regex_...,operator!=(3)

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

πŸ’… std::regex_...,operator!=(3) β€” C++ Standard Library, bestie edition

Okay so picture this: it's the std::regex_token_iterator page, and today we're doing its equality operators. Yes, both of them. Sit down, grab a strawberry πŸ“, this is actually so much simpler than it looks.


✨ NAME ✨

std::regex_token_iterator::operator==, operator!= β€” the twin operators that decide whether two regex token iterators are literally the same vibe or not.


🌸 Synopsis 🌸

bool operator==( const regex_token_iterator& other ) const; (1)
(since C++11)
bool operator!=( const regex_token_iterator& other ) const; (2)
(since C++11)
Heads up: there's an (until C++20) marker hanging out on this page, so keep that in mind for the timeline of these bad boys πŸ‘‘

So, what do they actually do? They check whether *this and other are equivalent. That's the whole assignment, no cap.

Two regex token iterators are equal if:

  • a) they are both end-of-sequence iterators. Bestie, if you're both at the end, you're the same. Slay.
  • b) they are both suffix iterators and the suffixes are equal. Matching suffixes = matching energy ✨
  • c) neither of them is an end-of-sequence iterator or a suffix iterator, and:
    • position == other.position
    • N == other.N
    • subs == other.subs

And then the numbered ones:

  1. Checks whether *this is equal to other.
  2. Checks whether *this is not equal to other.

Fun little glow-up era: the != operator is synthesized from operator==. (since C++20) So it's not doing its own thing anymore β€” it's just riding operator=='s coattails. Iconic behavior, honestly. πŸ¦‹

⚠️ This section is incomplete Reason: Explain better. For example, subs is an exposition-only vector of matched sub-expressions.

Not me leaving a todo in the docs 😭 but like β€” at least they're honest about it.


πŸŽ€ Parameters πŸŽ€

  • other β€” another regex token iterator to compare to. That's it. That's the parameter. Go off, king. 🫢

πŸ’– Return value πŸ’–

  1. true if *this is equal to other, false otherwise.
  2. true if *this is not equal to other, false otherwise.

No surprises, no plot twists, just good old-fashioned booleans. Periodt. πŸ’…


πŸ¦‹ Category πŸ¦‹

  • Todo with reason

And that's the whole page, bestie! 🌈

Signing off with the receipts: this one came from http://cppreference.com, dated 2024.06.10, and it's filed under std::regex_...,operator!=(3). Go forth and compare iterators responsibly βœ¨πŸ’œ

πŸ“¦ where this page comes from