Does C++11 offer a better way to concatenate strings on the fly?

13,681

C++11 introduces to_string() functions:

my_func("bla bla bla" + to_string(my_int) + "bla bla bla");
Share:
13,681
o0'.
Author by

o0'.

(Your about me is currently blank.)

Updated on June 07, 2022

Comments

  • o0'.
    o0'. almost 2 years

    I've seen this answer, and I wonder (I hope) if C++11 has come up with a native better method to concatenate, and possibly format, strings.

    With "better" I mean actually really one-line, like in pretty much all higher level languages (bonus points if it supports something like python's "formatted string"%(tuple) syntax but I guess that's really hoping for too much).

    The ideal result should be something like:

    my_func("bla bla bla" << int(my_int) << "bla bla bla");
    

    The only barely acceptable methods listed in that answer are the fastformat ones, but I wonder if C++11 managed to do better.