Boost logo

Boost :

From: Martin Wille (mw8329_at_[hidden])
Date: 2005-03-09 13:16:52


Eric Niebler wrote:

> I just uploaded to the Boost Sandbox File Vault a new and improved
> version of BOOST_FOREACH. Since much of the code is new, I removed many
> of the old work-arounds, so things are likely to break until the dust
> settles. I have verified it works on VC6+ and gcc 3.3.3.
>
> I would be especially interested in seeing results from BCC, EDG-based
> compilers, and GCC 2.9x. You can find foreach.zip at:
>
> http://tinyurl.com/5qhj8
> http://boost-sandbox.sourceforge.net/vault/index.php?directory=eric_niebler

> There is a simple regression test there and a Jamfile. If it doesn't
> compile, try defining BOOST_FOREACH_NO_CONST_RVALUE_DETECTION. If it
> still doesn't compiler, try defining BOOST_FOREACH_NO_RVALUE_DETECTION.
> Let me know the compiler version, and which macros you needed to define
> to get it to work.

gcc 2.95.3:

without #defines: foreach.hpp:27: Invalid token in expression
with NO_CONST_RVALUE_DETECTION: same error
with NO_RVALUE_DETECTION: same error

icc 8.1:

without #defines:
../../../boost/foreach.hpp(241): error: a new-initializer may not be
specified for an array
           ::new(data.address()) T(t);
                                   ^
           detected during:
             instantiation of
"boost::foreach::simple_variant<T>::simple_variant(const T &) [with
T=const int [5]]" at line 349
             instantiation of
"boost::foreach::auto_any<boost::foreach::simple_variant<const T>>
boost::foreach::contain(const T &, const bool &, boost::mpl::false_)
[with T=int [5]]" at line 88 of "regress.cpp"
             instantiation of "std::vector<int, std::allocator<int>>
to_vector_foreach_byval(Range &) [with Range=const int [5]]"

../../../boost/foreach.hpp(248): error: a new-initializer may not be
specified for an array
               ::new(data.address()) T(*that.get());
                                       ^
           detected during:
             instantiation of
"boost::foreach::simple_variant<T>::simple_variant(const
boost::foreach::simple_variant<T> &) [with T=const int [5]]" at line 113
             instantiation of
"boost::foreach::auto_any<T>::auto_any(const T &) [with
T=boost::foreach::simple_variant<const int [5]>]" at line 349
             instantiation of
"boost::foreach::auto_any<boost::foreach::simple_variant<const T>>
boost::foreach::contain(const T &, const bool &, boost::mpl::false_)
[with T=int [5]]" at line 88 of "regress.cpp"
             instantiation of "std::vector<int, std::allocator<int>>
to_vector_foreach_byval(Range &) [with Range=const int [5]]"

icc 8.1 with NO_CONST_RVALUE_DETECTION: works
icc 8.1 with NO_RVALUE_DETECTION: works

gcc 3.4.3, without #defines:
../../../boost/foreach.hpp: In copy constructor
`boost::foreach::simple_variant<T>::simple_variant(const
boost::foreach::simple_variant<T>&) [with T = const int[5]]':
regress.cpp:88: instantiated from `std::vector<int,
std::allocator<int> > to_vector_foreach_byval(Range&) [with Range =
const int[5]]'
regress.cpp:138: instantiated from here
../../../boost/foreach.hpp:248: error: ISO C++ forbids initialization in
array new
../../../boost/foreach.hpp: In constructor
`boost::foreach::simple_variant<T>::simple_variant(const T&) [with T =
const int[5]]':
../../../boost/foreach.hpp:349: instantiated from
`boost::foreach::auto_any<boost::foreach::simple_variant<const T> >
boost::foreach::contain(const T&, const bool&, mpl_::false_) [with T =
int[5]]'
regress.cpp:88: instantiated from `std::vector<int,
std::allocator<int> > to_vector_foreach_byval(Range&) [with Range =
const int[5]]'
regress.cpp:138: instantiated from here
../../../boost/foreach.hpp:241: error: ISO C++ forbids initialization in
array new

gcc 3.4.3, with NO_CONST_RVALUE_DETECTION: works
gcc 3.4.3, with NO_RVALUE_DETECTION: works

gcc-4, without #defines:
../../../boost/foreach.hpp: In copy constructor
'boost::foreach::simple_variant<T>::simple_variant(const
boost::foreach::simple_variant<T>&) [with T = const int [5]]':
regress.cpp:88: instantiated from 'std::vector<int,
std::allocator<int> > to_vector_foreach_byval(Range&) [with Range =
const int [5]]'
regress.cpp:138: instantiated from here
../../../boost/foreach.hpp:248: error: ISO C++ forbids initialization in
array new
../../../boost/foreach.hpp: In constructor
'boost::foreach::simple_variant<T>::simple_variant(const T&) [with T =
const int [5]]':
../../../boost/foreach.hpp:349: instantiated from
'boost::foreach::auto_any<boost::foreach::simple_variant<const T> >
boost::foreach::contain(const T&, const bool&, mpl_::false_) [with T =
int [5]]'
regress.cpp:88: instantiated from 'std::vector<int,
std::allocator<int> > to_vector_foreach_byval(Range&) [with Range =
const int [5]]'
regress.cpp:138: instantiated from here
../../../boost/foreach.hpp:241: error: ISO C++ forbids initialization in
array new

gcc 4, with NO_CONST_RVALUE_DETECTION: works
gcc 4, with NO_RVALUE_DETECTION: works

HTH,
m


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