Re: Using for each, in with STL containers with non-const iterators
- From: Ulrich Eckhardt <eckhardt@xxxxxxxxxxxxxx>
- Date: Thu, 01 Feb 2007 09:18:30 +0100
Wyck wrote:
I want to use the "for each, in" syntax with an STL container, and still[..]
modify the elements of the container while iterating.
I was expecting this to work:
for each( int& num in lst ) {
num++;
}
This 'for each' syntax doesn't exist in C++.
This is valid code:
for each( const int& cref in lst ) { /**/ }
...but 'cref' is not an l-value, so you can't modify the elements of the
list while iterating!
How are you compiling this? This for sure is not valid C++!
Uli
.
- Prev by Date: Re: Using for each, in with STL containers with non-const iterators
- Next by Date: Re: Using for each, in with STL containers with non-const iterators
- Previous by thread: Re: Using for each, in with STL containers with non-const iterators
- Next by thread: Re: Using for each, in with STL containers with non-const iterators
- Index(es):
Relevant Pages
|