I use a formatting library called fmt (http://fmtlib.net/latest/).
One of the possible use is :
fmt::format("Hello, {name}! The answer is {number}. Goodbye, {name}.", fmt::arg("name", "World"), fmt::arg("number", 42));
I'd like to wrap this call in a function that I'd call as :
myFunction(myString, {"name", "World"}, {"number", 42});
for any number of arguments.
Up to now,I only succeeded to do a function callable with a list of pairs :
myFunction(myString, std::make_pair("name", "World"), std::make_pair("number", 42));
with the function :
std::string myFunction(const char* str, const Args&... rest) const
{
return fmt::format(mLocale.getPOILabel(label), fmt::arg(rest.first, rest.second)...);
}
but I'd like not to have use pairs.
What should I do ?
PS : The fmt::arg
cannot be passed between functions.