Boost C++ Libraries: Ticket #11488: flat_map and value_type https://svn.boost.org/trac10/ticket/11488 <p> There is a problem with the value_type typedef. It is a typedef of std::pair&lt;Key, Value&gt; but shouldn't it be std::pair&lt;const Key, Value&gt;? </p> <p> typedef boost::unordered_map&lt;int, string&gt; Int2StringUmap; typedef boost::container::flat_map&lt;int, string&gt; Int2StringFmap; </p> <p> static_assert(std::is_same&lt;Int2StringUmap::value_type, std::pair&lt;const int, string&gt;&gt;::value, ""); <em>ok static_assert(std::is_same&lt;Int2StringFmap::value_type, std::pair&lt;const int, string&gt;&gt;::value, ""); </em>not ok </p> <p> Maybe already reported, but I couldn't find it in the svn. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11488 Trac 1.4.3 Ion Gaztañaga Thu, 11 Aug 2016 10:30:16 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11488#comment:1 https://svn.boost.org/trac10/ticket/11488#comment:1 <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">invalid</span> </li> </ul> <p> Reviewing old bugs. </p> <p> value_type is pair&lt;Key,Value&gt; as the internal type must be move constructible. This design is used since the pre-boost Loki <a class="missing wiki">AssocVector</a> associative container. </p> Ticket gast128@… Thu, 13 Apr 2017 15:29:17 GMT <link>https://svn.boost.org/trac10/ticket/11488#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11488#comment:2</guid> <description> <p> Ok I have to work around this then, e.g. the following code will not compile when fed with a flat_map const_iterator: </p> <div class="wiki-code"><div class="code"><pre> <span class="k">template</span> <span class="o">&lt;</span><span class="k">typename</span> <span class="n">Iterator</span><span class="o">&gt;</span> <span class="k">struct</span> <span class="nl">key_iterator</span> <span class="p">:</span> <span class="k">public</span> <span class="n">boost</span><span class="o">::</span><span class="n">bidirectional_iterator_helper</span><span class="o">&lt;</span><span class="n">key_iterator</span><span class="o">&lt;</span><span class="n">Iterator</span><span class="o">&gt;</span><span class="p">,</span> <span class="k">typename</span> <span class="n">std</span><span class="o">::</span><span class="n">iterator_traits</span><span class="o">&lt;</span><span class="n">Iterator</span><span class="o">&gt;::</span><span class="n">value_type</span><span class="o">::</span><span class="n">first_type</span><span class="o">&gt;</span> <span class="p">{</span> <span class="k">typedef</span> <span class="k">typename</span> <span class="n">base</span><span class="o">::</span><span class="n">value_type</span> <span class="n">value_type</span><span class="p">;</span> <span class="n">value_type</span><span class="o">&amp;</span> <span class="k">operator</span><span class="o">*</span> <span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">m_it</span><span class="o">-&gt;</span><span class="n">first</span><span class="p">;</span> <span class="p">}</span> <span class="k">private</span><span class="o">:</span> <span class="n">Iterator</span> <span class="n">m_it</span><span class="p">;</span> <span class="p">};</span> </pre></div></div> </description> <category>Ticket</category> </item> </channel> </rss>