Question

typedef map<wstring , IWString> REVERSETAG_CACHE ;
REVERSETAG_CACHE::iterator   revrsetagcacheiter;
.
.
.
wstring strCurTag;
strCurTag =  revrsetagcacheiter->second; //Error C2593

Error C2593: Operator = is ambiguous

Why does the above assignment give this error? It works in VC6. Does not compile in VC9.

Was it helpful?

Solution

revrsetagcacheiter->second is of type IWString . Hence it won't compile. I don't think it will compile in VC6 also.

I'll try one final time: Is your BasicString class c_str() method ? If so try converting it to wstring using std::wstring str(iter->second.c_str());

OTHER TIPS

At a guess, VC6 allows more than one user-defined conversion to be applied, while (correctly) VC9 does not. Take a look at C++ implicit conversions for discussion of the general problem.

The general solution is to supply the needed conversion yourself, rather than have the compiler try to do it.

Try to cast what your assigning to the correct type.

Such as:

strCurTag =  (wstring)revrsetagcacheiter->second;

Better yet, you may have meant:

IWstring strCurTag;

You should usually avoid implicit conversions, i.e. make all of your assignments work with exactly the same type at one side and the other, especially when it's trivial to know which types are involved. Relying, or trying to rely, on implicit conversions isn't a good idea.

So if:

strCurTag =  static_cast<wstring>(revrsetagcacheiter->second);

doesn't compile, then we should start thinking about the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top