Boost C++ Libraries: Ticket #13318: key_of_value now changes the type in the priority comparison for intrusive::treap_set https://svn.boost.org/trac10/ticket/13318 <p> Setting the <code>key_of_value</code> option now changes the type used in the priority comparison, which makes it impossible to use <code>key_of_value</code> when the priority is entirely separate to the primary key. </p> <p> The example below uses a comparison functor; a similar problem occurs with <code>priority_compare(T const&amp;, T const&amp;)</code> function. </p> <p> This worked in 1.59, fails to compile in 1.65.1. </p> <pre class="wiki">#include &lt;boost/intrusive/treap_set.hpp&gt; using namespace boost::intrusive; struct Test : public bs_set_base_hook&lt;&gt; { Test(int k, int p) : m_key(k), m_priority(p) {} int m_key; int m_priority; }; struct TestKey { using type = int; int const&amp; operator()(Test const&amp; t) const { return t.m_key; } }; struct PriorityCompare { bool operator()(Test const&amp; t1, Test const&amp; t2) const { return t1.m_priority &lt; t2.m_priority; } }; using Container = treap_set&lt;Test, key_of_value&lt;TestKey&gt;, priority&lt;PriorityCompare&gt;&gt;; int main() { Test t1(1, 2); Container c; c.insert(t1); } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13318 Trac 1.4.3 Jan Martin Mikkelsen <janm@…> Mon, 04 Dec 2017 23:55:03 GMT <link>https://svn.boost.org/trac10/ticket/13318#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13318#comment:1</guid> <description> <p> For reference, this is the error message produced. The compiler is Clang from Xcode 9. </p> <pre class="wiki">$ c++ -std=c++14 -I/usr/local/include/boost-1_65_1 test.cpp In file included from test.cpp:1: In file included from /usr/local/include/boost-1_65_1/boost/intrusive/treap_set.hpp:17: In file included from /usr/local/include/boost-1_65_1/boost/intrusive/treap.hpp:28: /usr/local/include/boost-1_65_1/boost/intrusive/priority_compare.hpp:46:14: error: no matching function for call to 'priority_order' return priority_order(val, val2); ^~~~~~~~~~~~~~ /usr/local/include/boost-1_65_1/boost/intrusive/detail/tree_value_compare.hpp:90:14: note: in instantiation of member function 'boost::intrusive::priority_compare&lt;int&gt;::operator()' requested here { return this-&gt;key_comp()(key1, KeyOfValue()(value2)); } ^ /usr/local/include/boost-1_65_1/boost/intrusive/detail/key_nodeptr_comp.hpp:110:14: note: in instantiation of member function 'boost::intrusive::tree_value_compare&lt;Test *, boost::intrusive::priority_compare&lt;int&gt;, TestKey, false&gt;::operator()' requested here { return base()(t1, *traits_-&gt;to_value_ptr(t2)); } ^ /usr/local/include/boost-1_65_1/boost/intrusive/treap_algorithms.hpp:651:33: note: in instantiation of function template specialization 'boost::intrusive::detail::key_nodeptr_comp&lt;boost::intrusive::priority_compare&lt;int&gt;, boost::intrusive::bhtraits&lt;Test, boost::intrusive::tree_node_traits&lt;void *&gt;, boost::intrusive::link_mode_type::safe_link, boost::intrusive::dft_tag, 6&gt;, TestKey&gt;::operator()&lt;int, const boost::intrusive::tree_node&lt;void *&gt; *&gt;' requested here while(upnode != header &amp;&amp; pcomp(k, upnode)){ ^ /usr/local/include/boost-1_65_1/boost/intrusive/treap_algorithms.hpp:493:10: note: in instantiation of function template specialization 'boost::intrusive::treap_algorithms&lt;boost::intrusive::tree_node_traits&lt;void *&gt; &gt;::rebalance_after_insertion_check&lt;int, boost::intrusive::detail::key_nodeptr_comp&lt;boost::intrusive::priority_compare&lt;int&gt;, boost::intrusive::bhtraits&lt;Test, boost::intrusive::tree_node_traits&lt;void *&gt;, boost::intrusive::link_mode_type::safe_link, boost::intrusive::dft_tag, 6&gt;, TestKey&gt; &gt;' requested here rebalance_after_insertion_check(header, commit_data.node, key, ... ^ /usr/local/include/boost-1_65_1/boost/intrusive/treap.hpp:662:28: note: in instantiation of function template specialization 'boost::intrusive::treap_algorithms&lt;boost::intrusive::tree_node_traits&lt;void *&gt; &gt;::insert_unique_check&lt;int, boost::intrusive::detail::key_nodeptr_comp&lt;std::__1::less&lt;int&gt;, boost::intrusive::bhtraits&lt;Test, boost::intrusive::tree_node_traits&lt;void *&gt;, boost::intrusive::link_mode_type::safe_link, boost::intrusive::dft_tag, 6&gt;, TestKey&gt;, boost::intrusive::detail::key_nodeptr_comp&lt;boost::intrusive::priority_compare&lt;int&gt;, boost::intrusive::bhtraits&lt;Test, boost::intrusive::tree_node_traits&lt;void *&gt;, boost::intrusive::link_mode_type::safe_link, boost::intrusive::dft_tag, 6&gt;, TestKey&gt; &gt;' requested here (node_algorithms::insert_unique_check ^ /usr/local/include/boost-1_65_1/boost/intrusive/treap.hpp:585:20: note: in instantiation of function template specialization 'boost::intrusive::treap_impl&lt;boost::intrusive::bhtraits&lt;Test, boost::intrusive::tree_node_traits&lt;void *&gt;, boost::intrusive::link_mode_type::safe_link, boost::intrusive::dft_tag, 6&gt;, TestKey, void, void, unsigned long, true, void&gt;::insert_unique_check&lt;int, std::__1::less&lt;int&gt;, boost::intrusive::priority_compare&lt;int&gt; &gt;' requested here { return this-&gt;insert_unique_check(key, this-&gt;key_comp(), this-&gt;priv... ^ /usr/local/include/boost-1_65_1/boost/intrusive/treap.hpp:499:45: note: in instantiation of member function 'boost::intrusive::treap_impl&lt;boost::intrusive::bhtraits&lt;Test, boost::intrusive::tree_node_traits&lt;void *&gt;, boost::intrusive::link_mode_type::safe_link, boost::intrusive::dft_tag, 6&gt;, TestKey, void, void, unsigned long, true, void&gt;::insert_unique_check' requested here std::pair&lt;iterator, bool&gt; ret = this-&gt;insert_unique_check(key_of_v... ^ /usr/local/include/boost-1_65_1/boost/intrusive/treap_set.hpp:240:25: note: in instantiation of member function 'boost::intrusive::treap_impl&lt;boost::intrusive::bhtraits&lt;Test, boost::intrusive::tree_node_traits&lt;void *&gt;, boost::intrusive::link_mode_type::safe_link, boost::intrusive::dft_tag, 6&gt;, TestKey, void, void, unsigned long, true, void&gt;::insert_unique' requested here { return tree_type::insert_unique(value); } ^ test.cpp:37:7: note: in instantiation of member function 'boost::intrusive::treap_set_impl&lt;boost::intrusive::bhtraits&lt;Test, boost::intrusive::tree_node_traits&lt;void *&gt;, boost::intrusive::link_mode_type::safe_link, boost::intrusive::dft_tag, 6&gt;, TestKey, void, void, unsigned long, true, void&gt;::insert' requested here c.insert(t1); ^ /usr/local/include/boost-1_65_1/boost/intrusive/priority_compare.hpp:32:6: note: candidate function template not viable: requires 0 arguments, but 2 were provided void priority_order(); ^ 1 error generated. </pre> </description> <category>Ticket</category> </item> </channel> </rss>