[Patch] First bits of the algo merge

Howard Hinnant hhinnant@apple.com
Thu Dec 15 15:04:00 GMT 2005


On Dec 15, 2005, at 9:55 AM, chris jefferson wrote:

>> It should look more like:
>>
>> template <class _Lhs, class _Rhs = _Lhs>
>> struct equal_to
>> {
>>     bool operator()(const _Lhs& __lhs, const _Lhs& __rhs) const
>> {return __lhs == __rhs;}
>>     bool operator()(const _Lhs& __lhs, const _Rhs& __rhs) const
>> {return __lhs == __rhs;}
>>     bool operator()(const _Rhs& __lhs, const _Lhs& __rhs) const
>> {return __lhs == __rhs;}
>>     bool operator()(const _Rhs& __lhs, const _Rhs& __rhs) const
>> {return __lhs == __rhs;}
>> };
>>
>> template <class _Lhs>
>> struct equal_to<_Lhs, _Lhs>
>> {
>>     bool operator()(const _Lhs& __lhs, const _Lhs& __rhs) const
>> {return __lhs == __rhs;}
>> };
>
> After chucking this through my own code, the only problem I found was
> you also need:
>
> template <class _Lhs>
> struct equal_to<_Lhs, const _Lhs>
> {
>     bool operator()(const _Lhs& __lhs, const _Lhs& __rhs) const  
> {return
> __lhs == __rhs;}
> };
>
> template <class _Lhs>
> struct equal_to<const _Lhs, _Lhs>
> {
>     bool operator()(const _Lhs& __lhs, const _Lhs& __rhs) const  
> {return
> __lhs == __rhs;}
> };
>
> to make equal_to<int, const int> work.

<nod> Excellent.

-Howard



More information about the Libstdc++ mailing list