diff --git a/xls/ir/value.h b/xls/ir/value.h index a7993fddb5..3fa08d0605 100644 --- a/xls/ir/value.h +++ b/xls/ir/value.h @@ -65,6 +65,21 @@ inline std::ostream& operator<<(std::ostream& os, ValueKind kind) { // some discussion around this, maybe they should be? class Value { public: + Value() : kind_(ValueKind::kInvalid), payload_(nullptr) {} + Value& operator=(const Value&) = default; + Value& operator=(Value&& v) { + kind_ = v.kind_; + payload_ = std::move(v.payload_); + v.kind_ = ValueKind::kInvalid; + v.payload_ = nullptr; + return *this; + } + Value(const Value&) = default; + Value(Value&& v) : kind_(v.kind_), payload_(std::move(v.payload_)) { + v.kind_ = ValueKind::kInvalid; + v.payload_ = nullptr; + } + static Value Tuple(absl::Span elements) { return Value(ValueKind::kTuple, elements); } @@ -115,8 +130,6 @@ class Value { UBits(/*value=*/static_cast(enabled), /*bit_count=*/1)); } - Value() : kind_(ValueKind::kInvalid), payload_(nullptr) {} - explicit Value(Bits bits) : kind_(ValueKind::kBits), payload_(std::move(bits)) {}