Is there a way to use operator+ to concatenate std::strings in c++? -
this question has answer here: what difference between these 2 cases of adding string? 5 answers i have function this void foo (const char* mystring){ ... } and want use this std::string tail = "something"; foo("my" + "string" + tail); but can't find easy way. sure can make string somewhere else , pass foo() . prefer find way inline, because foo() called several times in code, don't want make string each time. tried foo(std::string ("my" + "string" + tail).c_str()) but can guess doesn't work. "my" and "string" c style string literals, have odd rule concatenated if written without + . so "my" "string" + tail work, , produce std::string . however, still not correct type function, unless use .c_str() on result.