|
Boost : |
From: Chad Parry (spam_at_[hidden])
Date: 2005-08-25 17:15:46
(Resending to the Boost distribution list.)
I have a suggestion for the range_ex library. It is such a useful library --
IMHO, the Boost.Range library is useless without it. I would also like to
see it include a numeric.hpp that has a version of adjacent_difference, etc.
In my mind, any standard algorithm that takes an input iterator and an output
iterator as parameters could be rewritten as a range adaptor. I attached a
sample implementation. It's not done using Boost coding standards or
anything. BTW, I also found the "tail" (a.k.a. "pop_front") adaptor to be
useful in conjunction with adjacent_difference. Here's how I use it in my
toy project:
QuoteSum sum(
accumulate(
make_ResUse_range(result) |
boost::adaptor::transform(
boost::bind(adaptable_constructor<QuoteAddend>(),
boost::bind(&parseTimestampColumn,
boost::bind(&mysqlpp::Row::operator[], _1,
0)
),
boost::bind(&mysqlpp::Row::operator[], _1, 1)
)
) |
adjacent_difference() |
tail(),
QuoteSum(),
AccumulateQuotes(inverseYearDuration, annualMeanRate)
)
);
Thanks for the work that went into the library -- I hope it gets adopted. I
personally find it much more powerful than BOOST_FOREACH.
-- chad
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk