Effective implementation of algorithms (Master Thesis)
Effective and error-free implementation of algorithms
|
Go to the source code of this file.
Defines | |
#define | FOREACH(it, container) |
#define FOREACH | ( | it, | |
container | |||
) |
for( \
__typeof(container.begin()) it = container.begin(); \
it != container.end(); ++it)
foreach macro helps with enumerating stl containers. It iterates with newly-created iterator variable from begin of the container to the end.
Warning: FOREACH macro does not cache the container itself. This means, that calling FOREACH(it, functionReturningContainer()) will have unexpected behaviour!
Example usage: void annotate(const vector<string>& lines) { FOREACH(it, lines) { // it is of type vector<string>::iterator cout << "annotated line:" << *it; } }