Effective implementation of algorithms (Master Thesis)
Effective and error-free implementation of algorithms
src/utils/macros/foreach.h File Reference

Go to the source code of this file.

Defines

#define FOREACH(it, container)

Define Documentation

#define FOREACH (   it,
  container 
)
Value:
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; } }

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines