Boost C++ Libraries: Ticket #10336: compilation error in iterator_range and unordered_map https://svn.boost.org/trac10/ticket/10336 <p> I get a compilation error with vc10, iterator_range and a (const) unordered_map (the beta candidate 2 was still ok I think): </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&quot;stdafx.h&quot;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/iterator_range.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/unordered_map.hpp&gt;</span><span class="cp"></span> <span class="kt">int</span> <span class="nf">_tmain</span><span class="p">(</span><span class="kt">int</span> <span class="cm">/*argc*/</span><span class="p">,</span> <span class="n">_TCHAR</span><span class="o">*</span> <span class="cm">/*argv*/</span><span class="p">[])</span> <span class="p">{</span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">unordered_map</span><span class="o">&lt;</span><span class="kt">int</span><span class="p">,</span> <span class="kt">int</span><span class="o">&gt;</span> <span class="n">Container</span><span class="p">;</span> <span class="k">typedef</span> <span class="n">Container</span><span class="o">::</span><span class="n">const_iterator</span> <span class="n">ContainerIterator</span><span class="p">;</span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">iterator_range</span><span class="o">&lt;</span><span class="n">ContainerIterator</span><span class="o">&gt;</span> <span class="n">ContainerIteratorRange</span><span class="p">;</span> <span class="k">const</span> <span class="n">Container</span> <span class="n">cnt</span><span class="p">;</span> <span class="n">ContainerIteratorRange</span> <span class="n">rng</span><span class="p">(</span><span class="n">cnt</span><span class="p">.</span><span class="n">cbegin</span><span class="p">(),</span> <span class="n">cnt</span><span class="p">.</span><span class="n">cend</span><span class="p">());</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> This gives C2248: </p> <p> 'boost::unordered::iterator_detail::c_iterator&lt;Node,<a class="missing wiki">ConstNodePointer</a>&gt;::iterator' </p> <p> cannot access private typedef declared in class </p> <p> etc. </p> <p> Eric: Niebler: </p> <p> Well, this is unfortunate. It's broken also on msvc-12 and clang trunk, but strangely not on gcc. I thought it might be due to this change in Boost.Range: </p> <p> github.com/boostorg/range/commit/264017e2a9bdbfcc24517ce05f8ef96df0a8c45b </p> <p> But reverting that doesn't have any effect. It works on Boost 1.55, so this is definitely a regression. </p> <p> Can you please file a bug? Neil, can you take a look? </p> <p> A possible fix: github.com/boostorg/range/pull/19 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10336 Trac 1.4.3 Neil Groves Sun, 10 Aug 2014 16:12:07 GMT status changed https://svn.boost.org/trac10/ticket/10336#comment:1 https://svn.boost.org/trac10/ticket/10336#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket gast128@… Wed, 05 Nov 2014 10:56:23 GMT <link>https://svn.boost.org/trac10/ticket/10336#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10336#comment:2</guid> <description> <p> You can work around it: </p> <div class="wiki-code"><div class="code"><pre> <span class="k">const</span> <span class="n">ContainerIterator</span> <span class="n">itBegin</span> <span class="o">=</span> <span class="n">cnt</span><span class="p">.</span><span class="n">cbegin</span><span class="p">();</span> <span class="k">const</span> <span class="n">ContainerIterator</span> <span class="n">itEnd</span> <span class="o">=</span> <span class="n">cnt</span><span class="p">.</span><span class="n">cend</span><span class="p">();</span> <span class="n">ContainerIteratorRange</span> <span class="nf">rng</span><span class="p">(</span><span class="n">itBegin</span><span class="p">,</span> <span class="n">itEnd</span><span class="p">);</span> </pre></div></div><p> somehow the 'const' does the trick. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Neil Groves</dc:creator> <pubDate>Sat, 31 Jan 2015 14:52:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10336#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10336#comment:3</guid> <description> <p> I tested this today with Clang on OS X and could not reproduce the problem. I've added a unit test on the develop branch and will watch the tests cycle. </p> </description> <category>Ticket</category> </item> </channel> </rss>