Boost C++ Libraries: Ticket #13434: index_args_default_compare uses result_type https://svn.boost.org/trac10/ticket/13434 <p> I was trying to build with 'ISO C++17 Standard (/std:c++17)' mode in Visual Studio 2017 which removes unary_function and binary_function. </p> <p> Unfortunately index_args_default_compare gives then errors due to its dependency on result_type. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13434 Trac 1.4.3 Joaquín M López Muñoz Thu, 01 Feb 2018 19:52:24 GMT <link>https://svn.boost.org/trac10/ticket/13434#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13434#comment:1</guid> <description> <p> Hi, </p> <p> Could you please provide a little more context (test case, compiler output, etc.)? As far as I know all dependencies from <code>unary_function</code> and <code>binary_function</code> were suppresed at: </p> <p> <a class="ext-link" href="https://github.com/boostorg/multi_index/commit/7683cec9199073ca7f9b6efb7bb7f74a2cc8e01d"><span class="icon">​</span>https://github.com/boostorg/multi_index/commit/7683cec9199073ca7f9b6efb7bb7f74a2cc8e01d</a> </p> <p> Please note that, even though <code>index_args_default_compare</code> uses <code>KeyFromValue::result_type</code>, all available key extractors provide such nested <code>result_type</code> without using <code>std::[unary|binary]_function</code>. </p> </description> <category>Ticket</category> </item> <item> <author>gast128@…</author> <pubDate>Thu, 01 Feb 2018 21:08:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13434#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13434#comment:2</guid> <description> <p> I use Boost 1.65.1 with Visual studio 2017: </p> <div class="wiki-code"><div class="code"><pre><span class="k">template</span> <span class="o">&lt;</span><span class="k">class</span> <span class="nc">PairType</span><span class="o">&gt;</span> <span class="k">struct</span> <span class="n">select1st</span><span class="cm">/* : public std::unary_function&lt;PairType, typename PairType::first_type&gt;*/</span> <span class="p">{</span> <span class="k">const</span> <span class="k">typename</span> <span class="n">PairType</span><span class="o">::</span><span class="n">first_type</span><span class="o">&amp;</span> <span class="k">operator</span><span class="p">()(</span><span class="k">const</span> <span class="n">PairType</span><span class="o">&amp;</span> <span class="n">cr</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">cr</span><span class="p">.</span><span class="n">first</span><span class="p">;</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">typedef</span> <span class="n">std</span><span class="o">::</span><span class="n">pair</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">ClassEntry</span><span class="p">;</span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">multi_index</span><span class="o">::</span><span class="n">multi_index_container</span> <span class="o">&lt;</span> <span class="n">ClassEntry</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">multi_index</span><span class="o">::</span><span class="n">indexed_by</span> <span class="o">&lt;</span> <span class="n">boost</span><span class="o">::</span><span class="n">multi_index</span><span class="o">::</span><span class="n">ordered_non_unique</span><span class="o">&lt;</span><span class="n">select1st</span><span class="o">&lt;</span><span class="n">ClassEntry</span><span class="o">&gt;&gt;</span> <span class="o">&gt;</span> <span class="o">&gt;</span> <span class="n">ClassEntrySet</span><span class="p">;</span> <span class="n">ClassEntrySet</span> <span class="n">cntEntries</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> 1&gt;d:\develop\sdk and libraries\boost_1_65_1\boost\multi_index\detail\ord_index_args.hpp(46): error C2039: 'result_type': is not a member of 'select1st&lt;<a class="missing wiki">ClassEntry</a>&gt;' </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joaquín M López Muñoz</dc:creator> <pubDate>Fri, 02 Feb 2018 09:09:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13434#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13434#comment:3</guid> <description> <p> OK, I see. You have to define your user-provided extractor as follows: </p> <pre class="wiki">template &lt;class PairType&gt; struct select1st { typedef typename PairType::first_type result_type; const typename PairType::first_type&amp; operator()(const PairType&amp; cr) const { return cr.first; } }; </pre><p> I don't consider this a problem in the library, as the requirement that the key extractor have <code>::result_type</code> is not dependent on the existence (or lack thereof) of <code>std::unary_function</code>. Closing as invalid. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joaquín M López Muñoz</dc:creator> <pubDate>Fri, 02 Feb 2018 09:09:58 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/13434#comment:4 https://svn.boost.org/trac10/ticket/13434#comment:4 <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> Ticket gast128@… Fri, 02 Feb 2018 15:44:12 GMT <link>https://svn.boost.org/trac10/ticket/13434#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13434#comment:5</guid> <description> <p> Thx for looking into this issue. I can certainly work around the problem but one of the main responsibility of unary_function is the typedef of result_type. Afaic they shouldn't remove the unary_function if there is not a good alternative. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joaquín M López Muñoz</dc:creator> <pubDate>Sat, 03 Feb 2018 09:42:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13434#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13434#comment:6</guid> <description> <p> On the absence of <code>std::unary_function</code>, the simplest alternative is to write the nested <code>typedef</code> yourself as shown above. </p> <p> The rationale behind this removal is that C++11 and later allow for smarter ways of detecting the result type of <code>operator()</code> such as <a class="ext-link" href="http://en.cppreference.com/w/cpp/types/result_of"><span class="icon">​</span>std::result_of/std::invoke_result</a>: if Boost.MultiIndex had been written 10 years later, it'd have probably relied on one of these rather than requiring the user to provide <code>::result_type</code>. </p> </description> <category>Ticket</category> </item> </channel> </rss>