std::regex_...*,operator->(3)
π
std::regex_...*,operator->(3) π
Okay bestie, this is the manual page std::regex_...*,operator->(3) from the C++ Standard Libary β and yes, that's the header's spelling, not me π. It's all about the std::regex_iterator duo operator* and operator->, and it's giving tiny-accessor, big-match-results energy β¨.
π NAME π
std::regex_iterator::operator*,operator-> β std::regex_iterator::operator*,operator->
Yes, the page literally lists it twice like that. Not me, the manpage. π
β¨ Synopsis β¨
const value_type& operator*() const; (1) (since C++11)
const value_type* operator->() const; (2) (since C++11)
Extracts the current std::match_results from a regex_iterator. Slay. π
π Return value π
- Returns a reference to the current
std::match_results. - Returns a pointer to the current
std::match_results.
So operator* hands you the ref, and operator-> hands you the pointer. Both iconic, both since C++11. π«Ά
πΈ Example πΈ
// Run this code
#include <iostream>
#include <regex>
#include <string>
int main()
{
std::string hay{"1.1a2b3cjk34"};
std::regex needle("[1234]");
using Ri = std::regex_iterator<std::string::iterator>;
for (Ri it{hay.begin(), hay.end(), needle}, last{}; it != last;
++it)
std::cout << it->str();
std::cout << '\n';
}
Bestie, this example is lowkey cute: it walks hay with the needle regex [1234], and prints each match using it->str(). The operator-> is doing main character work here. ππ₯
π¦ Output π¦
112334
That's the whole page, bestie. Source/version:http://cppreference.comΒ· date:2024.06.10Β· footer page:std::regex_...*,operator->(3). Byeeee π π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms