<div dir="ltr"><div><div>Well, actually, having thought about it, the following might work:<br><br>template<typename T, typename U><br>struct IsEqComparable<br>{<br>private:<br>    typedef struct { char dmy; } yes;<br>
    typedef struct { char dmy[2]; } no;<br><br>    template<typename T2, typename U2><br>    static auto test(void*) -> typename std::enable_if<std::is_same<<br>            decltype(*std::declval<T2>().begin() == *std::declval<U2>().begin()),<br>
            decltype(*std::declval<T2>().begin() == *std::declval<U2>().begin())<br>        >::value, yes>::type;<br><br>    template<typename T2, typename U2> static no test(...);<br>public:<br>    static const bool value = sizeof(test<T, U>(nullptr)) == sizeof(yes);<br>
};<br><br></div>This works fine for comparing vectors and probably any other container that exposes iterators through begin.<br>You will have to detect the possible type of the types, though.<br><br>The problem essentially comes from that there exists an operator == that compares two vectors, hence decltype(a == b) would succeed, because decltype does not evaluate its arguments.<br>
</div>Instead, the problem happens inside the operator == when it tries to compare the elements.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 29 May 2013 09:27, Stephen Kelly <span dir="ltr"><<a href="mailto:steveire@gmail.com" target="_blank">steveire@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">Mailing List Email wrote:<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
That is unfortunate. I am afraid that, at  this moment, I do not know of a<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
better solution. It would seem that  decltype erroneously makes the<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
overloaded well-formed while the idea was  that it should not.<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Perhaps someone else will have another  suggestion.<br>
</blockquote>
<br>
<br></div>
It appears there is no known solution. Boost hit the same problem:<br>
<br>
<br>
<a href="http://stackoverflow.com/questions/16791391/determining-whether-containert-containert-can-compile" target="_blank">http://stackoverflow.com/<u></u>questions/16791391/<u></u>determining-whether-<u></u>containert-containert-can-<u></u>compile</a><br>

<br>
<br>
However, as I wrote before, the problem becomes solvable if trailing return types are used:<div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
>> Adding auto and trailing  return type seems to be helpful:<br>
</blockquote></blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
>><br>
</blockquote></blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
>>  <a href="http://thread.gmane.org/gmane.comp.lib.qt.devel/11120/focus=11157" target="_blank">http://thread.gmane.org/gmane.<u></u>comp.lib.qt.devel/11120/focus=<u></u>11157</a><br>
</blockquote></blockquote>
<br>
<br>
<br></div>
So, I'm wondering if we can change libcxx to use trailing return types for operators like that? Would such a change have to go into the c++ standard itself?<br>
<br>
<br>
Thanks,<br>
<br>
<br>
Steve<br>
<br>
</blockquote></div><br></div>