[cfe-dev] Determining whether Container<T>()==Container<T>() can compile?

Mailing List Email mailinglistx at gmail.com
Tue May 28 10:23:10 PDT 2013


That is unfortunate. I am afraid that, at this moment, I do not know of a
better solution. It would seem that decltype erroneously makes the
overloaded well-formed while the idea was that it should not.
Perhaps someone else will have another suggestion.


On 28 May 2013 11:48, Stephen Kelly <steveire at gmail.com> wrote:

> Mailing List Email wrote:
>
> > It can be done yourself, or am I misunderstanding your question?
> > Example:
>
> >     if (IsEqComparable<std::vector<int>, std::vector<int>>::value)
> >         std::cout << "Yes!\n";
> >     else
> >         std::cout << "No!\n";
>
>
> Thanks for the suggestion.
>
> Your solution does not work for nested containers, however:
>
>
>     if (IsEqComparable<std::vector<bar>, std::vector<bar> >::value)
>         std::cout << "Yes!\n";
>     else
>         std::cout << "No!\n";
>
> outputs "Yes!".
>
> Does that make the problem more clear? Any further suggestions?
>
> Thanks,
>
> Steve
>
>
> >
> > On 24 May 2013 10:41, Stephen Kelly
> > <steveire at gmail.com> wrote:
> >
> >>
> >> Hi there,
> >>
> >> Code such as
> >>
> >>   std::vector<A> veca, vecb;
> >>   veca == vecb;
> >>
> >> can only compile if A()==A() can compile, if you'll forgive me taking
> >> some descriptive shortcuts.
> >>
> >> I tried writing a template to determine if a type can be
> >> equality-compared for the purpose of type-erasure:
> >>
> >>  http://thread.gmane.org/gmane.comp.lib.qt.devel/11120
> >>
> >> Adding auto and trailing return type seems to be helpful:
> >>
> >>  http://thread.gmane.org/gmane.comp.lib.qt.devel/11120/focus=11157
> >>
> >> Would the suggestion from Olivier Goffart be something that could be
> >> applied
> >> to libcxx to make it possible to write such a template for its stl
> >> container
> >> implementations?
> >>
> >> Does anyone else have any other ideas for something that would work with
> >> todays stl implementations?
> >>
> >> Thanks,
> >>
> >> Steve.
> >>
> >>
> >> _______________________________________________
> >> cfe-dev mailing list
> >> cfe-dev at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> >>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130528/8dc0468c/attachment.html>


More information about the cfe-dev mailing list