Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2001-07-26 21:37:23


On Thursday 26 July 2001 07:44, you wrote:
> John Maddock wrote:
> > boost success = mystring >> myregex
> > std::string s = mystring >> myregex/myformat
>
> I'd have thought that
>
> regex / string
>
> should yield an iterator into the match groups container:
>
> for(g = regex / string; g++; g) {
> cout << "group = " << *g << endl;
> }
>
> and hence
>
> if(regex/string)...
>
>
> works because it yields a 'null' iterator if the comparison fails.
> To substitute the groups into the format string:
>
> (regex/string) >> format
>
> to reference group 3:
>
> (regex/string)[3]
>
>
> Another possibility is just:
>
> m = regex/string;
> for (g = m.begin(); g++; m.end()) ..
>
>
> ie. regex/string is a standard container supporting
> random iterators.

Very interesting... I think this would be a reasonable addition, though at
some point we're getting past the original intention of the 'perlish' syntax:
a concise (somewhat familiar) syntax for simple pattern matching tasks.

Though I do wonder at what point we've gone too far in the abuse of operator
overloading.

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk