mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
Mark move constructors as "noexcept"
I recently learned that move constructors generally should be marked "noexcept". This ensures that standard containers will move objects when possible, rather than copy them. This patch fixes the cases I could find. Note that implicitly-defined or defaulted move constructors will automatically do what you'd expect; that is, they are noexcept if all the members have noexcept move constructors. While doing this, I noticed a couple of odd cases where the move constructor seemed to assume that the object being constructed could have state requiring destruction. I've fixed these as well. See completion_result and scoped_mmap. gdb/ChangeLog 2020-04-20 Tom Tromey <tromey@adacore.com> * python/python.c (struct gdbpy_event): Mark move constructor as noexcept. * python/py-tui.c (class gdbpy_tui_window_maker): Mark move constructor as noexcept. * completer.h (struct completion_result): Mark move constructor as noexcept. * completer.c (completion_result::completion_result): Use initialization style. Don't call reset_match_list. gdbsupport/ChangeLog 2020-04-20 Tom Tromey <tromey@adacore.com> * scoped_mmap.h (scoped_mmap): Mark move constructor as noexcept. Use initialization style. Don't call destroy. * scoped_fd.h (class scoped_fd): Mark move constructor as noexcept. * gdb_ref_ptr.h (class ref_ptr): Mark move constructor as noexcept.
This commit is contained in:
@@ -30,7 +30,7 @@ class scoped_fd
|
||||
public:
|
||||
explicit scoped_fd (int fd = -1) noexcept : m_fd (fd) {}
|
||||
|
||||
scoped_fd (scoped_fd &&other)
|
||||
scoped_fd (scoped_fd &&other) noexcept
|
||||
: m_fd (other.m_fd)
|
||||
{
|
||||
other.m_fd = -1;
|
||||
|
||||
Reference in New Issue
Block a user