Boost logo

Boost Users :

Subject: [Boost-users] Boost.Format for variadic numbers of arguments
From: Philipp Moeller (philipp.moeller_at_[hidden])
Date: 2012-02-20 05:43:27


I currently have a lot of code that formats list into something
readable.

Is it possible to do something like:

  boost::format fmt("List [ %V,%]");

  std::vector<std::string> c = {"foo", "bar" };
  std::for_each(begin(c), end(c), [&fmt](const std::string& x)
                                  { fmt % x; });

Where V would indicate a variable list and the character constant
immediately after it would be the separator. (I'm not sure about V as a
parameter, but someone more familiar with the library might have an
answer to that.)

Alternatively, suggestions for a flexible container pretty printer would
be welcome as well.

Cheers,
Philipp Moeller


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net