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

Stephen Kelly steveire at gmail.com
Tue May 28 02:48:26 PDT 2013


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
>>





More information about the cfe-dev mailing list