Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi-index] foreach supports breaks compilation
From: Rob Desbois (rob.desbois_at_[hidden])
Date: 2011-11-16 06:09:00


Hi Szymon,

On 16 November 2011 10:40, Szymon Gatner <szymon.gatner_at_[hidden]> wrote:

> I realize this is not really a multi-index bug but after I updated
> from 1.47 to 1.48
> my code no longer compiles due to this code:
>
> template<typename SuperMeta,typename TagList>
> inline boost::mpl::true_* boost_foreach_is_noncopyable(
> boost::multi_index::detail::sequenced_index<SuperMeta,TagList>*&,
> boost::foreach::tag)
> {
> return 0;
> }

> ...snip...
>
> this happens because as suggested in boost.foreach docs I have this
> earlier:
>
> #define foreach BOOST_FOREACH
>

I'm not certain whether there's anything under-the-hood of multi_index that
could do this, but since #define foreach BOOST_FOREACH was just an example,
and the user could define any PP token to expand as such, a change to
multi_index could only ever work around that one example.

I see a couple of possibilities for you: either #undef foreach before the
above code, then #define it again afterwards, or use a name other than
'foreach'. Unfortunately (or not) this is just the way PP macros work, and
why avoiding them is desirable - they are not namespaceable unlike real
types & names.

--rob

-- 
Rob Desbois
Eml: rob.desbois_at_[hidden]
Blog: http://theotherbranch.wordpress.com/
Tel: 07946 705987
"I disapprove of what you say, but I’ll defend to the death your right to
say it", Voltaire


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