ug4
vec_for_each.h File Reference

Go to the source code of this file.

Macros

#define end_for   }
 Allows iteration over all members of an std::vector compatible type. More...
 
#define for_each_in_vec(_vfeDecl, _vfeVec)
 Allows iteration over all members of an std::vector compatible type. More...
 

Macro Definition Documentation

◆ end_for

#define end_for   }

Allows iteration over all members of an std::vector compatible type.

Use e.g. like this:

std::vector<T> vec;
//...
for_each_in_vec(T& t, vec){
t.memberFunc();
#define for_each_in_vec(_vfeDecl, _vfeVec)
Allows iteration over all members of an std::vector compatible type.
Definition: vec_for_each.h:52
#define end_for
Allows iteration over all members of an std::vector compatible type.
Definition: vec_for_each.h:56

The '{' and '}' brackets are hereby optional, since a new block is automatically defined between 'for_each_in_vec' and 'end_for'.

The specified vector has to feature methods 'T& operator[](size_t i)' and 'size_t size()'.

◆ for_each_in_vec

#define for_each_in_vec (   _vfeDecl,
  _vfeVec 
)
Value:
for(size_t _vfeI = 0; _vfeI < _vfeVec.size(); ++_vfeI){\
_vfeDecl = _vfeVec[_vfeI];

Allows iteration over all members of an std::vector compatible type.

Use e.g. like this:

std::vector<T> vec;
//...
for_each_in_vec(T& t, vec){
t.memberFunc();

The '{' and '}' brackets are hereby optional, since a new block is automatically defined between 'for_each_in_vec' and 'end_for'.

The specified vector has to feature methods 'T& operator[](size_t i)' and 'size_t size()'.