c++boostformatboost-format

How to create / combine / concatenate boost::format from multiple boost::format


This is given:

boost::format greeting("%s (Greeting)");
boost::format name("%s (Name)");

'greetingwithname' should combine and reuses 'greeting' and 'name' so that it is equivalent to this:

boost::format greetingwithname("%s (Greeting) %s (Name)");
// looking for solution to like boost::format greetingwithname = greeting + name;

How do I / What is the best way to create a boost::format object from multiple boost:format objects?


Solution

  • It is not possible to concatenate the boost::format objects, but as @sehe commented you can concatenate the format strings instead and create a format object from that.