Boost C++ Libraries: Ticket #1814: foreach broken by is_char_array mpl assertion. https://svn.boost.org/trac10/ticket/1814 <p> please consider following testcase that works fine with boost-1.34: </p> <pre class="wiki">struct IV { typedef std::vector&lt; int &gt; C; typedef C::const_iterator const_iterator; virtual const_iterator begin() const = 0; virtual const_iterator end() const = 0; }; void test_foreach( IV const&amp; iv ) { BOOST_FOREACH( int i, iv ) { } } </pre><p> with boost-1.35 i got an error: </p> <pre class="wiki">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&lt;T,C&gt;::IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING23' being compiled (...) </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1814 Trac 1.4.3 pluto@… Fri, 11 Apr 2008 09:41:28 GMT <link>https://svn.boost.org/trac10/ticket/1814#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1814#comment:1</guid> <description> <p> afaics the problem is in the BOOST_MPL_ASSERT_MSG invocation. the last parameter T leads to an abstract type instantitation. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Fri, 11 Apr 2008 16:27:29 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/1814#comment:2 https://svn.boost.org/trac10/ticket/1814#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/44182" title="work with abstract classes, fixes #1814">[44182]</a>) work with abstract classes, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1814" title="#1814: Bugs: foreach broken by is_char_array mpl assertion. (closed: fixed)">#1814</a> </p> Ticket Eric Niebler Fri, 11 Apr 2008 16:40:53 GMT <link>https://svn.boost.org/trac10/ticket/1814#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1814#comment:3</guid> <description> <p> 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. </p> <p> If you would like to make the change locally, the simple fix is to change this: </p> <pre class="wiki"> BOOST_MPL_ASSERT_MSG( (!is_char_array&lt;T&gt;::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T) ); </pre><p> to this: </p> <pre class="wiki"> BOOST_MPL_ASSERT_MSG( (!is_char_array&lt;T&gt;::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T&amp;) ); </pre><p> Note the <code>(T&amp;)</code> at the end, rather than the <code>(T)</code>. </p> </description> <category>Ticket</category> </item> </channel> </rss>