On 19 Aug 2004 00:56:10 -0700,
prakash.bande@altair.com (Prakash
Bande) wrote:
[color=blue]
>Hi,
>I have bool operator == (xx* obj, const string st). I have declared it
>as friend of class xx. I am now able to do this:
>xx ox;
>string st;
>if (&ox == st)
>{
>}
>But, when I have a vector<xx*> and use stl find
>string xyz;
>vector<xx*>::iterator i = find(ii, xv.end(), xyz);
>
>c:\program files\include\algorithm(43) : error C2679: binary '==' : no
>operator defined which takes a right-hand operand of type 'const class
>std::basic_string<char,struct std::char_traits<char>,class
>std::allocator<char> >' (or there is no acceptab
>le conversion)
>
>Here is a code snippet:
>
>#include "stdafx.h"
>#include <string>
>#include <vector>
>#include <iostream.h>[/color]
That should be
#include <iostream>
(many latest version compilers, including MSVC7.1 don't even have
<iostream.h>, and it is non-standard).
With that one change, it compiles and links fine (on VC7.1, for one).
I think your compiler doesn't implement argument dependent lookup, so
it doesn't find your globally declared operator, but instead only
finds the various operator==s declared in std. You may want to
upgrade.
Tom