Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi-index][foreach] Iterating over a sequence index (worked in 1.46, broke in 1.47)
From: Michel MORIN (mimomorin_at_[hidden])
Date: 2011-07-31 16:34:40


> Michel MORIN <mimomorin <at> gmail.com> writes:
>> GCC 4.6 (in C++03 mode) changes the behavior of rvalue conversion.
>> This affects the way of lvalue/rvalue detection in Boost.Foreach;
>> then compilation error occurs.
>>
>> To detect detecting lvalue/rvalue, Boost.Foreach tries to copy
>> `sequenced_index` (though the copy is never executed…).
>> However, the copy ctor of `sequenced_index` is protected,
>> and so the compile error emitted.

This description might be insufficient. So let me explain it again.

GCC 4.6 changes the behavior of rvalue conversion.
This affects the way of lvalue/rvalue detection in Boost.Foreach:
  * On GCC 4.6, Boost.Foreach detects it at run time.
  * On GCC 4.5 and prior versions, Boost.Foreach detects it at compile time.
(Note that, in Boost 1.46 and prior versions, Boost.Foreach incorrectly uses
compile-time detection on GCC 4.6.)

When detecting lvalue/rvalue at run time, Boost.Foreach tries to copy
`sequenced_index`. However, its copy ctor is protected, and so
the compile error emitted. To avoid this, we need to tell Boost.Foreach
not to copy `sequenced_index` by specializing `is_noncopyable`
or overloading `boost_foreach_is_noncopyable`.

Compile-time lvalue/rvalue detection does not cause any problem with
`sequenced_index`. Considering the fact that many compilers (VC++ 7.1
and newer versions, GCC 3.4-4.5) support compile-time detection,
it is not surprising that the compatibility issue between Boost.MultiIndex
and Boost.Foreach did not occur in the past. But it's just that the problem
did not surface in the past; on compilers that use run-time detection,
the problem has existed from the beginning.

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