<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On 26 August 2013 22:01, Daniel Krügler <span dir="ltr">&lt;<a href="mailto:daniel.kruegler@gmail.com" target="_blank">daniel.kruegler@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">2013/8/26 Ville Voutilainen &lt;<a href="mailto:ville.voutilainen@gmail.com">ville.voutilainen@gmail.com</a>&gt;:<br>
<div><div class="h5">&gt; On 26 August 2013 19:00, Jeffrey Yasskin &lt;<a href="mailto:jyasskin@google.com">jyasskin@google.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; The library&#39;s running into problems because &lt; is unspecified on<br>
&gt;&gt; pointers that don&#39;t point to the same object. (C++14CD[expr.rel]p4)<br>
&gt;&gt; Naively, this restriction makes a bit of sense, since we can&#39;t give a<br>
&gt;&gt; particular answer for any two pointers, but it&#39;s causing problems for<br>
&gt;&gt; some generic library components. Specifically:<br>
&gt;&gt;<br>
&gt;&gt; std::map&lt;T*&gt; works because std::less has a special case for pointers.<br>
&gt;&gt; ([comparisons]p14)<br>
&gt;&gt;<br>
&gt;&gt; std::map&lt;std::tuple&lt;T*&gt;&gt; gives undefined behavior because<br>
&gt;&gt; std::less&lt;tuple&gt; uses tuple&#39;s operator&lt;, which uses T*&#39;s operator&lt;.<br>
&gt;&gt;<br>
&gt;&gt; std::map&lt;std::optional&lt;T*&gt;&gt; goes back to defined behavior because we<br>
&gt;&gt; special-cased optional&#39;s operator&lt; to use std::less:<br>
&gt;&gt; [optional.relops]p4<br>
&gt;<br>
&gt; I have strong reasons to believe we&#39;ll see an NB comment proposing std::less<br>
&gt; to be specialized for tuple&lt;T*&gt; and containers.<br>
<br>
</div></div>I don&#39;t understand why there should be different specializations<br>
instead of a single specialization:<br>
<br>
less&lt;tuple&lt;T...&gt;&gt;<br>
<br>
which defines the operator() overload in terms of std::less&lt;T&gt; for<br>
each T in order. Same thing for pair and optional and containers.<br>
<span class="HOEnZb"><font color="#888888"><br><br></font></span></blockquote><div><br></div><div>Sounds like a reasonable approach to me. <br></div></div><br></div></div>