It’s very pointless and troublesome that everytime that you need to concatenate two strings it is necessary to do at least:
std::string mystr = std::string("Hello") + " World";
I would like to overload operator+ and use it in order to always do a concat between tho char* in this way:
std::string mystr = "Ciao " + "Mondo".
How would you do? I’d like to find a best practice. Thank you…
Ah does boost have something to solve this?
You cannot make
+work like this. To define an operator overload, at least one of the operands must be a user-defined type.However, the functionality is built in: if you just put two string literals together
"like" "this", they will automatically be joined together at compile time.