
Compare: // (1) my typical use, where Map is a typedef or a template parameter foreach (Map::reference val, map) { action(val.first, val.second); } // (2) use based on typedef'd container foreach_pair (Map::key_type const &key, Map::referent_type &val, map) { action(key, val); } // (3) use references foreach_pair (Key const &key, Value &val, map) { action(key, val); } // (4) copying without a typedef foreach_pair (Key key, Val val, map) { action(key, val); } A hidden cost of (3) and (4) is the extra work required when refactoring. On Tue, Sep 15, 2009 at 10:22 AM, Pete Bartlett <pete@pcbartlett.com> wrote:
Christian Schladetsch wrote:
Is there any performance difference between
BOOST_FOREACH_PAIR(K const &key, V &val, map) { }
and
BOOST_FOREACH(Map::reference ref, map) { }
I haven't tested this specific case but in previous discussions and tests on this subject, I found these extra for-loops of fixed "length" 1 hidden in the macro expansion were optimized well by popular compilers, so the hit may be negligible.
Pete
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost