From e5a0365b010bff96432486ad2b572cb7c2bf4b1a Mon Sep 17 00:00:00 2001 From: zyfncg Date: Wed, 27 Apr 2022 10:09:51 +0800 Subject: [PATCH] Add move construct for KernelSignature (#42253) * add move construct for KernelSignature * add noexcept --- paddle/phi/core/compat/arg_map_context.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/paddle/phi/core/compat/arg_map_context.h b/paddle/phi/core/compat/arg_map_context.h index 5b693124221..cd7eb419f13 100644 --- a/paddle/phi/core/compat/arg_map_context.h +++ b/paddle/phi/core/compat/arg_map_context.h @@ -63,6 +63,13 @@ 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; @@ -70,6 +77,14 @@ struct KernelSignature { 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); -- GitLab