Commit acfd3382 by Aaron Jacobs Committed by Copybara-Service

inlined_vector: remove excess restrictions on copy constructor fast path.

The copy constructor isn't doing or simulating copy assignment; nor is it
destroying anything. We don't need to require that those operations be trivial.

PiperOrigin-RevId: 521020499
Change-Id: I0f36a720384b333ea15e6c8275872fd4fd9a738f
parent 6a37c26a
......@@ -189,18 +189,8 @@ class InlinedVector {
// allocator doesn't do anything fancy, and there is nothing on the heap
// then we know it is legal for us to simply memcpy the other vector's
// inlined bytes to form our copy of its elements.
//
// TODO(b/274984172): the condition on copy-assignability is here only for
// historical reasons. It doesn't make semantic sense: we don't need to be
// able to copy assign here, we are doing an "as-if" copy construction.
//
// TODO(b/274984172): the condition on trivial destructibility is here only
// for historical reasons. It doesn't make sense: there is no destruction
// here.
if (absl::is_trivially_copy_constructible<value_type>::value &&
std::is_same<A, std::allocator<value_type>>::value &&
absl::is_trivially_copy_assignable<value_type>::value &&
absl::is_trivially_destructible<value_type>::value &&
!other.storage_.GetIsAllocated()) {
storage_.MemcpyFrom(other.storage_);
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment