#1814 closed Bugs (fixed)
foreach broken by is_char_array mpl assertion.
| Reported by: | Owned by: | Eric Niebler | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | foreach | 
| Version: | Boost 1.35.0 | Severity: | Regression | 
| Keywords: | Cc: | 
Description
please consider following testcase that works fine with boost-1.34:
struct IV
{
	typedef std::vector< int > C;
	typedef C::const_iterator const_iterator;
	virtual const_iterator begin() const = 0;
	virtual const_iterator end() const = 0;
};
void test_foreach( IV const& iv )
{
	BOOST_FOREACH( int i, iv )
	{
	}
}
with boost-1.35 i got an error:
boost/foreach.hpp(357) : error C2259: 'IV' : cannot instantiate abstract class
        due to following members:
        'IV::const_iterator IV::begin(void) const' : is abstract
(...)
        'IV::const_iterator IV::end(void) const' : is abstract
(...)
        boost/foreach.hpp(357) : see reference to class template instantiation 'boost::foreach_detail_::foreach_iterator<T,C>::IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING23' being compiled (...)
      Change History (3)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
comment:3 by , 15 years ago
This problem had already been fixed in trunk, but the fix didn't make it into the release branch in time for 1.35. I have merged the fix into the release branch in case there is a 1.35.1 release.
If you would like to make the change locally, the simple fix is to change this:
BOOST_MPL_ASSERT_MSG( (!is_char_array<T>::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T) );
to this:
BOOST_MPL_ASSERT_MSG( (!is_char_array<T>::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T&) );
Note the (T&) at the end, rather than the (T).
  Note:
 See   TracTickets
 for help on using tickets.
    

afaics the problem is in the BOOST_MPL_ASSERT_MSG invocation. the last parameter T leads to an abstract type instantitation.