|
![](/i/fill.gif) |
Invisible <voi### [at] dev null> wrote:
> On 10/05/2012 03:41 PM, Le_Forgeron wrote:
> > You will be delighted by the C++11 range-based for loop:
> >
> > for(auto i : whateverSTL)
> > {
> > // here you have all the element of the container as i, one at a time
> >
> > }
> >
> >
> > no need for template, just basic code.
> STL?
> As in Standard TEMPLATE Library?
> Yeah, no templates here. ;-)
The range-based for loop works with static arrays, initializer lists
and any object that either has a begin() and an end() member function
that return forward iterators, or which have std::begin() and std::end()
equivalents. Templates are not a requirement.
The range-based for is especially designed to traverse STL data
containers, but them being templated has nothing to do with it.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |