mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-27 12:49:46 +01:00
Improve exception safety in dynamic_format_arg_store
This commit is contained in:
@@ -284,7 +284,7 @@ FMT_NORETURN FMT_API void assert_fail(const char* file, int line,
|
||||
|
||||
#ifndef FMT_ASSERT
|
||||
# ifdef NDEBUG
|
||||
// FMT_ASSERT is not empty to avoid -Werror=empty-body.
|
||||
// FMT_ASSERT is not empty to avoid -Werror=empty-body.
|
||||
# define FMT_ASSERT(condition, message) ((void)0)
|
||||
# else
|
||||
# define FMT_ASSERT(condition, message) \
|
||||
@@ -1236,11 +1236,11 @@ class dynamic_arg_list {
|
||||
|
||||
public:
|
||||
template <typename T, typename Arg> const T& push(const Arg& arg) {
|
||||
auto next = std::move(head_);
|
||||
auto node = new typed_node<T>(arg);
|
||||
head_.reset(node);
|
||||
head_->next = std::move(next);
|
||||
return node->value;
|
||||
auto node = std::unique_ptr<typed_node<T>>(new typed_node<T>(arg));
|
||||
auto& value = node->value;
|
||||
node->next = std::move(head_);
|
||||
head_ = std::move(node);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
} // namespace internal
|
||||
|
||||
Reference in New Issue
Block a user