diff --git a/xla/layout.h b/xla/layout.h index 24cee4b8a6445..3002e4af23066 100644 --- a/xla/layout.h +++ b/xla/layout.h @@ -156,7 +156,7 @@ class Layout { public: Layout(); Layout(const Layout& other); - Layout(Layout&& other); + Layout(Layout&& other) noexcept; ~Layout(); // Constructs a dense layout with the given minor-to-major order. @@ -181,7 +181,7 @@ class Layout { int64_t dynamic_shape_metadata_prefix_bytes = 0); Layout& operator=(const Layout& other); - Layout& operator=(Layout&& other); + Layout& operator=(Layout&& other) noexcept; // Construct a shape from a LayoutProto. static Layout CreateFromProto(const LayoutProto& proto); diff --git a/xla/literal.h b/xla/literal.h index 3233126a5efb0..d97be36272a9e 100644 --- a/xla/literal.h +++ b/xla/literal.h @@ -1362,13 +1362,13 @@ class Literal : public MutableLiteralBase { // of literals which can be expensive. Literal(const Literal& other) = delete; Literal& operator=(const Literal& other) = delete; - Literal(Literal&& other); + Literal(Literal&& other) noexcept; // 'allocate_arrays' indicates whether to allocate memory for the arrays in // the shape. If false, buffer pointers inside of the Literal::Pieces are set // to nullptr. Literal(const Shape& shape, bool allocate_arrays, ArrayValueState leaf_array_value_state = ArrayValueState::kKnown); - Literal& operator=(Literal&& other); + Literal& operator=(Literal&& other) noexcept; // Similar to CopyFrom, but with move semantics. The subshape of this literal // rooted at 'dest_shape_index' must be *equal* to the shape 'src_literal' diff --git a/xla/maybe_owning.h b/xla/maybe_owning.h index 4f32472ecb2f9..b53d4c2777eb6 100644 --- a/xla/maybe_owning.h +++ b/xla/maybe_owning.h @@ -52,14 +52,14 @@ class MaybeOwning final { return *this; } - MaybeOwning& operator=(MaybeOwning&& other) { + MaybeOwning& operator=(MaybeOwning&& other) noexcept { using std::swap; swap(ptr_and_owning_bit_, other.ptr_and_owning_bit_); return *this; } MaybeOwning(const MaybeOwning&) = delete; - MaybeOwning(MaybeOwning&& other) + MaybeOwning(MaybeOwning&& other) noexcept : ptr_and_owning_bit_(other.ptr_and_owning_bit_) { other.ptr_and_owning_bit_ = 0; }