El 06/11/2016 a las 15:46, Vinnie Falco escribió:
One question, how do you iterate over all the objects of a particular type in a container using a range-for? I see begin() and end() overloads which take a std::type index but if I want to visit all the "warrior" objects (from your example) in a given container `c`, what expression do I put in place of R below:
for(auto& sprite : R) { ... }
In its current state the lib does not provide syntax sugar for this. The alternatives are for(auto first=c.begin<warrior>(),last=c.end<warrior>();first!=last;++first){ ... // work with *first } std::for_each(c.begin<warrior>(),c.end<warrior>(),[](auto& sprite){ ... } for(auto& sprite:boost::make_iterator_range(c.begin<warrior>(),c.end<warrior>())){ ... } This is not to say that this particular feature couldn't be in principle added to the lib. Joaquín M López Muñoz