Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi-index] foreach supports breaks compilation
From: Michel Morin (mimomorin_at_[hidden])
Date: 2011-11-16 10:36:40


Szymon Gatner wrote:
>> If you can control the ordering, you can avoid the problem.
>> But this solution is error prone.
>
> Yup, can't really do this now.

Making your own header file and defining `foreach` macro in the header
might be a better solution:

    // my_foreach.h
    #include <boost/foreach.hpp>

    #include <boost/multi_index_container.hpp>
    #include <boost/multi_index/hashed_index.hpp>
    #include <boost/multi_index/ordered_index.hpp>
    #include <boost/multi_index/random_access_index.hpp>
    #include <boost/multi_index/sequenced_index.hpp>

    #define foreach BOOST_FOREACH

Then, whenever you use `foreach`, include this header file.
By doing so, you don't have to worry about the ordering of
header files and the macro definition.

Regards,
Michel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net