MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / SlowMoveAssign

Method SlowMoveAssign

common/values/value_variant.cc:280–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void ValueVariant::SlowMoveAssign(ValueVariant& other, bool trivial,
281 bool other_trivial) noexcept {
282 ABSL_DCHECK(!trivial || !other_trivial);
283
284 if (trivial) {
285 switch (other.index_) {
286 case ValueIndex::kBytes:
287 ::new (static_cast<void*>(&raw_[0]))
288 BytesValue(std::move(*other.At<BytesValue>()));
289 break;
290 case ValueIndex::kString:
291 ::new (static_cast<void*>(&raw_[0]))
292 StringValue(std::move(*other.At<StringValue>()));
293 break;
294 case ValueIndex::kError:
295 ::new (static_cast<void*>(&raw_[0]))
296 ErrorValue(std::move(*other.At<ErrorValue>()));
297 break;
298 case ValueIndex::kUnknown:
299 ::new (static_cast<void*>(&raw_[0]))
300 UnknownValue(std::move(*other.At<UnknownValue>()));
301 break;
302 default:
303 ABSL_UNREACHABLE();
304 }
305 index_ = other.index_;
306 kind_ = other.kind_;
307 flags_ = other.flags_;
308 } else if (other_trivial) {
309 switch (index_) {
310 case ValueIndex::kBytes:
311 At<BytesValue>()->~BytesValue();
312 break;
313 case ValueIndex::kString:
314 At<StringValue>()->~StringValue();
315 break;
316 case ValueIndex::kError:
317 At<ErrorValue>()->~ErrorValue();
318 break;
319 case ValueIndex::kUnknown:
320 At<UnknownValue>()->~UnknownValue();
321 break;
322 default:
323 ABSL_UNREACHABLE();
324 }
325 FastMoveAssign(other);
326 } else {
327 switch (index_) {
328 case ValueIndex::kBytes:
329 switch (other.index_) {
330 case ValueIndex::kBytes:
331 *At<BytesValue>() = std::move(*other.At<BytesValue>());
332 break;
333 case ValueIndex::kString:
334 At<BytesValue>()->~BytesValue();
335 ::new (static_cast<void*>(&raw_[0]))
336 StringValue(std::move(*other.At<StringValue>()));
337 index_ = other.index_;

Callers

nothing calls this directly

Calls 1

FastMoveAssignFunction · 0.85

Tested by

no test coverage detected