Can placement-new and vector::data() be used to replace elements in a vector?
问题 There are two existing questions about replacing vector elements that are not assignable: C++ Use Unassignable Objects in Vector How to push_back without operator=() for const members? A typical reason for an object to be non-assignable is that its class definition includes const members and therefore has its operator= deleted. std::vector requires that its element type be assignable. And indeed, at least using GCC, neither direct assignment ( vec[i] = x; ), nor a combination of erase() and