Quick question: I’d like to glue a number of TString variables together and give this new combination of TStrings to a function as parameter. I do not need the combined string anywhere else only as a parameter in one function. Is there some elegant and quick way to do this without doing a sprintf or such, i.e. something like
TString String1 = "foo";
TString String2 = "bar";
TString String3 = "gar";
MyFunction(String1 + String2 + String3);
would be nice, without having to declare a new TString which contains “foobargar” just to give it to the function.
Try with “std::string” instead of “TString”.
I will. Is there an “elegant” way to convert from std::string to TString and vice versa? Elegant means something like
Atoi() which converts to int.
In answer to your first post, I would recommend instead using TString::Format to create the rvalue TString. So instead of having three TStrings you could to MyFunction(TString::Format(“foo%sbaz”,“bar”) or something.
For the second, to convert between std::strings and TStrings you basically have to first get the underlying c-string. Something like:
The TString::Data and std::string::c_str methods return the underlying c-string for TStrings and std::strings, respectively.