Boost.Foreach is a C++ library containing a macro for easily iterating over the elements of a sequence.
Boost.Foreach is a C++ library containing a macro for easily iterating over the elements of a sequence.
The BOOST_FOREACH
macro is designed for ease-of-use and efficiency. It does no dynamic allocations, makes no virtual function calls or calls through function pointers, and makes no calls that are not transparent to the compiler's optimizer. This results in near-optimal code generation; the performance of BOOST_FOREACH
is usually within a few percent of the equivalent hand-coded loop. And although BOOST_FOREACH
is a macro, it is a remarkably well-behaved one. It evaluates its arguments exactly once, leading to no nasty surprises.