Skip to content

Commit

Permalink
Add move construct for KernelSignature (#42253)
Browse files Browse the repository at this point in the history
* add move construct for KernelSignature

* add noexcept
  • Loading branch information
zyfncg authored Apr 27, 2022
1 parent a679492 commit e5a0365
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions paddle/phi/core/compat/arg_map_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,28 @@ struct KernelSignature {
input_names(other.input_names),
attr_names(other.attr_names),
output_names(other.output_names) {}

KernelSignature(KernelSignature&& other) noexcept
: name(other.name),
input_names(std::move(other.input_names)),
attr_names(std::move(other.attr_names)),
output_names(std::move(other.output_names)) {}

KernelSignature& operator=(const KernelSignature& other) {
name = other.name;
input_names = other.input_names;
attr_names = other.attr_names;
output_names = other.output_names;
return *this;
}

KernelSignature& operator=(KernelSignature&& other) noexcept {
name = other.name;
input_names.swap(other.input_names);
attr_names.swap(other.attr_names);
output_names.swap(other.output_names);
return *this;
}
};

std::ostream& operator<<(std::ostream& os, KernelSignature signature);
Expand Down

0 comments on commit e5a0365

Please sign in to comment.