Skip to content

Commit

Permalink
[clang-tidy] Add noexcept where move is used
Browse files Browse the repository at this point in the history
Found with performance-noexcept-move-constructor

Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb authored and vitaut committed Nov 8, 2019
1 parent e6e8298 commit bb0c8bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,14 +607,14 @@ class basic_memory_buffer : private Allocator, public internal::buffer<T> {
of the other object to it.
\endrst
*/
basic_memory_buffer(basic_memory_buffer&& other) { move(other); }
basic_memory_buffer(basic_memory_buffer&& other) FMT_NOEXCEPT { move(other); }

/**
\rst
Moves the content of the other ``basic_memory_buffer`` object to this one.
\endrst
*/
basic_memory_buffer& operator=(basic_memory_buffer&& other) {
basic_memory_buffer& operator=(basic_memory_buffer&& other) FMT_NOEXCEPT {
assert(this != &other);
deallocate();
move(other);
Expand Down
4 changes: 2 additions & 2 deletions include/fmt/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class buffered_file {
other.file_ = nullptr;
}

buffered_file& operator=(buffered_file&& other) {
buffered_file& operator=(buffered_file&& other) FMT_NOEXCEPT {

This comment has been minimized.

Copy link
@0x8000-0000

0x8000-0000 Nov 27, 2019

Contributor

This should not be FMT_NOEXCEPT because it calls close which is not FMT_NOEXCEPT; in fact it throws.

close();
file_ = other.file_;
other.file_ = nullptr;
Expand Down Expand Up @@ -209,7 +209,7 @@ class file {

file(file&& other) FMT_NOEXCEPT : fd_(other.fd_) { other.fd_ = -1; }

file& operator=(file&& other) {
file& operator=(file&& other) FMT_NOEXCEPT {
close();
fd_ = other.fd_;
other.fd_ = -1;
Expand Down

0 comments on commit bb0c8bf

Please sign in to comment.