Boost C++ Libraries: Ticket #10370: Iterating over ptr_map type is largely broken in 1.56 https://svn.boost.org/trac10/ticket/10370 <p> Iteration over map fails on most types, except for value. Not sure which version this failure began, but definitely present in 1.56 </p> <p> The following simple snippet will fail: </p> <blockquote> <p> typedef boost::ptr_map&lt;int, int&gt; test_map_type; test_map_type test_map; </p> </blockquote> <blockquote> <p> BOOST_FOREACH(test_map_type::const_reference r, test_vector ) { </p> </blockquote> <blockquote> <p> } </p> </blockquote> <p> Will also fail with reference, iterator, const_iterator. boost::tie also fails. Can iterate by value, but this does not help with my application since the mapped type will be an abstract type (so no clone allocator for mapped type) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10370 Trac 1.4.3 Eric Niebler Tue, 19 Aug 2014 04:56:39 GMT keywords, owner, component changed https://svn.boost.org/trac10/ticket/10370#comment:1 https://svn.boost.org/trac10/ticket/10370#comment:1 <ul> <li><strong>keywords</strong> foreach removed </li> <li><strong>owner</strong> changed from <span class="trac-author">Eric Niebler</span> to <span class="trac-author">Thorsten Ottosen</span> </li> <li><strong>component</strong> <span class="trac-field-old">foreach</span> → <span class="trac-field-new">ptr_container</span> </li> </ul> <p> This test case shows the problem is specific to ptr_container and has nothing to do with <code>BOOST_FOREACH</code>. </p> <pre class="wiki">#include &lt;boost/ptr_container/ptr_map.hpp&gt; int main() { typedef boost::ptr_map&lt;int, int&gt; test_map_type; test_map_type test_map; test_map_type::const_reference r = *test_map.begin(); } </pre><p> For me, this gives: </p> <pre class="wiki">1&gt;f:\scratch\scratch\main.cpp(9): error C2440: 'initializing' : cannot convert from 'boost::ptr_container_detail::ref_pair&lt;F,S&gt;' to 'boost::ptr_container_detail::ref_pair&lt;F,S&gt;' 1&gt; with 1&gt; [ 1&gt; F=int 1&gt; , S=int *const 1&gt; ] 1&gt; and 1&gt; [ 1&gt; F=int 1&gt; , S=const int *const 1&gt; ] 1&gt; No constructor could take the source type, or constructor overload resolution was ambiguous </pre> Ticket anonymous Tue, 19 Aug 2014 19:21:09 GMT <link>https://svn.boost.org/trac10/ticket/10370#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10370#comment:2</guid> <description> <p> Discovered that switching compiler flag to c++11 resolved the problem. Maybe this problem is specific to GNU compiler without c++11 enabled? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Tue, 19 Aug 2014 20:42:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10370#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10370#comment:3</guid> <description> <p> I was seeing it on msvc 2013. </p> </description> <category>Ticket</category> </item> </channel> </rss>