mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Allow getting size of dynamic format arg store (#4270)
This commit is contained in:
parent
873670ba3f
commit
7c50da5385
@ -210,6 +210,9 @@ template <typename Context> class dynamic_format_arg_store {
|
||||
data_.reserve(new_cap);
|
||||
named_info_.reserve(new_cap_named);
|
||||
}
|
||||
|
||||
/// Returns the number of elements in the store.
|
||||
size_t size() const noexcept { return data_.size(); }
|
||||
};
|
||||
|
||||
FMT_END_NAMESPACE
|
||||
|
@ -186,3 +186,17 @@ TEST(args_test, move_constructor) {
|
||||
store.reset();
|
||||
EXPECT_EQ(fmt::vformat("{} {} {a1}", moved_store), "42 foo foo");
|
||||
}
|
||||
|
||||
TEST(args_test, size) {
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
EXPECT_EQ(store.size(), 0);
|
||||
|
||||
store.push_back(42);
|
||||
EXPECT_EQ(store.size(), 1);
|
||||
|
||||
store.push_back("Molybdenum");
|
||||
EXPECT_EQ(store.size(), 2);
|
||||
|
||||
store.clear();
|
||||
EXPECT_EQ(store.size(), 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user