Range adaptor for adjacent_difference

(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

(Sorry for the delay. I've been on the road and my bandwith has been very limitted.) Chad Parry wrote:
I have a suggestion for the range_ex library. It is such a useful library -- IMHO, the Boost.Range library is useless without it.
Thanks! I know Thorsten feels similarly and would like to see it become an official part of Boost.Range. I would also like to
see it include a numeric.hpp that has a version of adjacent_difference, etc.
Oh, yeah. The numeric algorithms. I forgot about those. Thanks for reminding me!
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.
Interesting.
Thanks for the work that went into the library -- I hope it gets adopted. I personally find it much more powerful than BOOST_FOREACH.
I choose to take this as a compliment. :-) Between dealing with FOREACH test failures and getting xpressive ready for review, I haven't had much time for the range algorithms and adaptors. After the dust has settled a bit, I hope to get back to thinking abouut Range (unless you or Thorsten beats me to it). Thanks for the suggestions and the code. They are most welcome. -- Eric Niebler Boost Consulting www.boost-consulting.com
participants (2)
-
Chad Parry
-
Eric Niebler