Board index » cppbuilder » AnsiString not compatible with basic_string

AnsiString not compatible with basic_string


2003-11-19 02:15:56 PM
cppbuilder109
Hi all,
when I have a component with a caption and want fill it with
a std::string I have to use the c_str() function:
string text;
text = "Button";
Button1->Caption = text.c_str();
This is not fine, because the string is converted to a char* and
then converted again to an AnsiString...
Is there a better possibility ??
Thanks Mauro
 
 

Re:AnsiString not compatible with basic_string

"Mauro" < XXXX@XXXXX.COM >wrote in message
Quote
This is not fine
Why not?
Quote
the string is converted to a char*
It is not converted to a char*. It is already a char* to begin with. The
c_str() method simply returns a pointer to the std::string's internal
buffer. The same is true of AnsiString's c_str() method as well.
Quote
and then converted again to an AnsiString...
So?
Quote
Is there a better possibility ??
No. The STL has no concept of the AnsiString class, and AnsiString has no
concept of the str::string class. Passing char* pointers back and forth is
the only commonality they have with each other, since they both support
char* pointers.
Gambit