cxxomfort
rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
|
Foreach emulation
Cxxomfort implements emulation of C++11's "foreach" or for(item: collection)
, for systems without C++11.
The interface is provided via the CXXO_FOREACH macro and is used as follows:
This feature allows working with sequences and ranges transparently up to the limits established by the compiler. Currently foreach support in cxxomfort goes as follows:
for (itemdecl : collection)
and is fully compatible with eg.: ref rvalues. range-for iteration, incurring in no cost.typeof
(eg.: GCC 4.x, Clang), this makes use of typeof to implement something similar to for (unspecified_iterator b = begin(collection), e = end(collection) ; b != e ; ++b) if(itemdecl) ...
. typeof
support (eg.: MSVC 2008-2010), a type-eraed interface is built using the same base that the original Artima article on foreach emulation provides. This has the cost of one virtual function call per iteration.