<div dir="ltr"><div>It can be done yourself, or am I misunderstanding your question?<br>Example:<br><br>#include <iostream><br></div>#include <vector><br><div>#include <type_traits><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>() == std::declval<U2>()),<br>            decltype(std::declval<T2>() == std::declval<U2>())<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>struct bar {};<br><br>int main()<br>{<br>    if (IsEqComparable<std::vector<int>, std::vector<int>>::value)<br>
        std::cout << "Yes!\n";<br>    else<br>        std::cout << "No!\n";<br>    if (IsEqComparable<std::vector<int>, bar>::value)<br>        std::cout << "Yes!\n";<br>
    else<br>        std::cout << "No!\n";<br>    return 0;<br>}<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 24 May 2013 10:41, 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"><br>
Hi there,<br>
<br>
Code such as<br>
<br>
  std::vector<A> veca, vecb;<br>
  veca == vecb;<br>
<br>
can only compile if A()==A() can compile, if you'll forgive me taking some<br>
descriptive shortcuts.<br>
<br>
I tried writing a template to determine if a type can be equality-compared<br>
for the purpose of type-erasure:<br>
<br>
 <a href="http://thread.gmane.org/gmane.comp.lib.qt.devel/11120" target="_blank">http://thread.gmane.org/gmane.comp.lib.qt.devel/11120</a><br>
<br>
Adding auto and trailing return type seems to be helpful:<br>
<br>
 <a href="http://thread.gmane.org/gmane.comp.lib.qt.devel/11120/focus=11157" target="_blank">http://thread.gmane.org/gmane.comp.lib.qt.devel/11120/focus=11157</a><br>
<br>
Would the suggestion from Olivier Goffart be something that could be applied<br>
to libcxx to make it possible to write such a template for its stl container<br>
implementations?<br>
<br>
Does anyone else have any other ideas for something that would work with<br>
todays stl implementations?<br>
<br>
Thanks,<br>
<br>
Steve.<br>
<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div>