mirror of
https://github.com/fmtlib/fmt.git
synced 2026-05-04 19:44:09 +02:00
Add support for dynamic arg sets
This allows construction of basic_format_args from a dynamic set of arguments. The syntax is a little clunky and could probably be improved but this at least enables the functionality.
This commit is contained in:
committed by
Victor Zverovich
parent
cf2719bd12
commit
b1d10a2884
@@ -1316,6 +1316,17 @@ TEST(FormatTest, Variadic) {
|
||||
EXPECT_EQ(L"abc1", format(L"{}c{}", L"ab", 1));
|
||||
}
|
||||
|
||||
TEST(FormatTest, Dynamic) {
|
||||
using ctx = fmt::format_context;
|
||||
std::vector<fmt::basic_format_arg<ctx>> args;
|
||||
args.emplace_back(fmt::internal::make_arg<ctx>(42));
|
||||
args.emplace_back(fmt::internal::make_arg<ctx>("abc1"));
|
||||
args.emplace_back(fmt::internal::make_arg<ctx>(1.2f));
|
||||
|
||||
std::string result = fmt::vformat("{} and {} and {}", fmt::basic_format_args<ctx>(args.data(), (unsigned)args.size()));
|
||||
EXPECT_EQ("42 and abc1 and 1.2", result);
|
||||
}
|
||||
|
||||
TEST(FormatTest, JoinArg) {
|
||||
using fmt::join;
|
||||
int v1[3] = { 1, 2, 3 };
|
||||
|
||||
Reference in New Issue
Block a user