|
Boost Users : |
From: David Abrahams (dave_at_[hidden])
Date: 2006-03-08 07:59:23
"Andy Little" <andy_at_[hidden]> writes:
> FWIW Heres some sample code. Its seems a bit lopsided!
>
> std::ofstream out("toolpath_out.txt");
>
> BOOST_FOREACH(boost::shared_ptr<section> sp,vect){
>
> if (sp->m_action == section::reverse){
> for( std::vector<std::string>::reverse_iterator iter
> = sp->m_vector.rbegin();
> iter != sp->m_vector.rend();
> ++iter){
> out << *iter << '\n';
> }
> }
> else {
> BOOST_FOREACH(std::string str,sp->m_vector){
> out << str << '\n';
> }
> }
> }
>
> Are there any plans for a BOOST_REVERSE_FOREACH?
I suggest you just make a nice reverse adaptor that models Range,
wrapping the underlying iterators in boost::reverse_iterator, and an
object generator that builds instances. Then you can
BOOST_FOREACH( whatever, reverse_view( the_sequence ) )
...
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net