Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-11-18 07:41:12


Eric,
I've some questions about BOOST_FOREACH (which is pretty cool, BTW).

1. Is it possible to use typeof on gcc, to avoid any possible overhead? While
you've posted some results which show that gcc generally can optimise it very
well, I'd like to be 100% sure). Something like:

 #define FOR_EACH(var, container) \
   for(typeof(container.begin()) _for_each_i = container.begin(),\
      _for_each_e = container.end();\
      _for_each_i != _for_each_e; ++_for_each_i)\
    if(bool _for_each_continue = false) {}\
    else\
       for(var = *_for_each_i; !_for_each_continue; _for_each_continue=true)

which works perfectly for me.

2. Any chance that

     BOOST_FOREACH((pair<int, int> p), container)

will work? I don't know how to make it work without require paranthethis in
all cases, but maybe there's a smart trick.

3. Is it possible that you place this to sandbox, for easier access?

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk