On 01/23/2011 06:21 AM, Andrei Alexandrescu wrote:
On 1/22/11 10:59 PM, Jonathan M Davis wrote:
This will be a _fantastic_ function to have. I think that I probably even have
an enhancement request somewhere that includes such a function. It's far too
common that you have to find something and you want both what is before and
after
the point that you find. Now, that being the case, I'd probably more commonly
find
it useful to get the part before what was found and then the part beginning with
what was found, but this works too.

I suspect there might be a simple and intuitive way to define a family of
functions that give you whatever portions of the find you're interested in
(before, match, after, before and match, match and after). That could be either
a naming convention or a template argument. Any ideas, let me know.

Andrei

Guess (tell me if I'm wrong) english says "cut into pieces". Thus, I would consider a paradigm starting with either cut- or piece-/pieces-.

<Side-note> I still find that find- (!) is wrong for funcs like findParts, even knowing the current find function actually returns the part match-and-after. Actually, it's find trying to do too much imo, should just return the (first) match; what anybody else would expect, or what? Thus, the name does not fit, the semantics is unexpected, and weird errors are to come.
        auto bigNumber = find!("a>10")(numbers); // too bad!
        // Next applicant, please ;-)
Note I'm not at all against Andrei's generalised algos --on the contrary. But having them too smart at the price of beeing counter-intuitive is wrong imo.
</Side-note>

Denis
_________________
vita es estrany
spir.wikidot.com

Reply via email to