Boost C++ Libraries: Ticket #10315: multi_index composite_key find() doesn't work with std::tuple https://svn.boost.org/trac10/ticket/10315 <p> com_key_index.find (boost::make_tuple(...)) works. While com_key_index.find (std::make_tuple(...)) doesn't compile. </p> <p> Using gcc4.8.1 with -std=c++11 </p> <p> Sample code: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;tuple&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/tuple/tuple.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/multi_index_container.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/multi_index/member.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/multi_index/ordered_index.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/multi_index/composite_key.hpp&gt;</span><span class="cp"></span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">std</span><span class="p">;</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">multi_index</span><span class="p">;</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="p">;</span> <span class="k">struct</span> <span class="n">Point</span> <span class="p">{</span> <span class="n">string</span> <span class="n">x</span><span class="p">;</span> <span class="n">string</span> <span class="n">y</span><span class="p">;</span> <span class="kt">unsigned</span> <span class="n">w</span><span class="p">;</span> <span class="p">};</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="k">struct</span> <span class="n">PointX</span> <span class="p">{};</span> <span class="k">struct</span> <span class="n">PointYW</span> <span class="p">{};</span> <span class="n">multi_index_container</span><span class="o">&lt;</span><span class="n">Point</span><span class="p">,</span><span class="n">indexed_by</span><span class="o">&lt;</span> <span class="n">ordered_unique</span> <span class="o">&lt;</span><span class="n">tag</span><span class="o">&lt;</span><span class="n">PointX</span><span class="o">&gt;</span><span class="p">,</span> <span class="n">member</span><span class="o">&lt;</span><span class="n">Point</span><span class="p">,</span> <span class="n">string</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">Point</span><span class="o">::</span><span class="n">x</span><span class="o">&gt;&gt;</span><span class="p">,</span> <span class="n">ordered_unique</span> <span class="o">&lt;</span><span class="n">tag</span><span class="o">&lt;</span><span class="n">PointYW</span><span class="o">&gt;</span><span class="p">,</span> <span class="n">composite_key</span><span class="o">&lt;</span><span class="n">Point</span><span class="p">,</span> <span class="n">member</span><span class="o">&lt;</span><span class="n">Point</span><span class="p">,</span> <span class="n">string</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">Point</span><span class="o">::</span><span class="n">y</span><span class="o">&gt;</span><span class="p">,</span> <span class="n">member</span><span class="o">&lt;</span><span class="n">Point</span><span class="p">,</span> <span class="kt">unsigned</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">Point</span><span class="o">::</span><span class="n">w</span><span class="o">&gt;</span> <span class="o">&gt;&gt;</span> <span class="o">&gt;&gt;</span> <span class="n">points</span><span class="p">;</span> <span class="n">points</span><span class="p">.</span><span class="n">get</span><span class="o">&lt;</span><span class="n">PointX</span><span class="o">&gt;</span><span class="p">().</span><span class="n">emplace</span> <span class="p">(</span><span class="n">Point</span><span class="p">{</span><span class="s">&quot;A&quot;</span><span class="p">,</span> <span class="s">&quot;B&quot;</span><span class="p">,</span> <span class="mi">1</span><span class="p">});</span> <span class="n">points</span><span class="p">.</span><span class="n">get</span><span class="o">&lt;</span><span class="n">PointYW</span><span class="o">&gt;</span><span class="p">().</span><span class="n">find</span> <span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="s">&quot;B&quot;</span><span class="p">,</span> <span class="mi">1</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> By replacing std::make_tuple --&gt; boost::make_tuple, it does compile. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10315 Trac 1.4.3 Joaquín M López Muñoz Wed, 06 Aug 2014 07:27:02 GMT type changed https://svn.boost.org/trac10/ticket/10315#comment:1 https://svn.boost.org/trac10/ticket/10315#comment:1 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Feature Requests</span> </li> </ul> <p> Hi Chris, </p> <p> Yes, composite keys do not interoperate with <code>std::tuple</code>s, basically because the former predate the latter by a number of years. Changing this ticket to "feature request". I hope to be able to find some time to do this, but don't hold your breath :-) </p> Ticket christephan@… Wed, 06 Aug 2014 07:52:51 GMT <link>https://svn.boost.org/trac10/ticket/10315#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10315#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10315#comment:1" title="Comment 1">joaquin</a>: </p> <blockquote class="citation"> <p> Hi Chris, </p> <p> Yes, composite keys do not interoperate with <code>std::tuple</code>s, basically because the former predate the latter by a number of years. Changing this ticket to "feature request". I hope to be able to find some time to do this, but don't hold your breath :-) </p> </blockquote> <p> Very thanks~ I'm using <code>boost::make_tuple</code> by now~ The only pity thing is there is no <code>boost::forward_as_tuple</code>~ </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joaquín M López Muñoz</dc:creator> <pubDate>Wed, 20 Aug 2014 09:45:52 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10315#comment:3 https://svn.boost.org/trac10/ticket/10315#comment:3 <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> Here you go: </p> <p> <a class="ext-link" href="https://github.com/boostorg/multi_index/commit/6d6bb7550460503b27da72c2c583344b1e99f50b"><span class="icon">​</span>https://github.com/boostorg/multi_index/commit/6d6bb7550460503b27da72c2c583344b1e99f50b</a> </p> <p> I've just pushed the commit, so regression testers might still reveal some glitches uncovered by my local tests; be warned in case you try this yourself locally. </p> Ticket