|
Boost : |
From: Eric Niebler (eric_at_[hidden])
Date: 2004-12-19 00:05:24
BOOST_FOREACH is a macro which makes it simple to iterate over a
sequence. It is concise, and clearly expresses the programmer's
intentions. For example:
short array_short[] = {1,2,3};
BOOST_FOREACH( short & i, array_short )
{
++i;
}
// array_short contains {2,3,4} here
Recent changes I have made to the macro have greatly increased its
safety and usefulness. It gracefully handles both L-value and R-value
sequence expression, and evaluates its arguments only once. It now works
(to a greater or lesser extent) on a wide range of compilers, even VC6.
The current implementation, documentation and tests can be found in the
Boost Sandbox File Vault. You can download the Zip file here:
Tinyurl link redirects to:
http://boost-sandbox.sourceforge.net/vault/index.php?action=downloadfile&filename=foreach.zip&directory=eric_niebler&
-- Eric Niebler Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk