Board index » cppbuilder » variant / ansistring conversion

variant / ansistring conversion


2006-06-02 04:16:48 PM
cppbuilder42
This code stopped "working" in BDS 2006
Variant v;
AnsiString a( v );
gives error [C++ Error] E2015 Ambiguity between '_fastcall
AnsiString::AnsiString(const WideString &)' and '_fastcall
AnsiString::AnsiString(const AnsiString &)'
I have to rewrite it to
AnsiString a( v.operator AnsiString() );
isn't the compiler required to find the direct conversion from one type
to the other by the standard (if such exists)?
the fact that there exist an AnsiString ctor for WideString and an
operator WideString() for Variant shouldn't be considered at all?
or is my memory of the standard wrong?
Someone with more certain knowledge of this, that take's the task of
putting it into QC?
btw, why did it work in BCB 6 ?
--
frode
 
 

Re:variant / ansistring conversion

Quote
isn't the compiler required to find the direct conversion from one type
to the other by the standard (if such exists)?
AnsiString has a constructor that can take either an AnsiString or a
WideString. Variant has operators for both. The compiler has no idea which
one you actually want to use, so you must explicitly tell it which one to
use.
Mark