BoundedInlineVector: Add resize() method
Bug: webrtc:11391 Change-Id: I34d659d0e295617e9058393d4d1b510111a78b83 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/169520 Commit-Queue: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30664}
This commit is contained in:
@ -45,6 +45,16 @@ void InitializeElements(T* data, U&& element, Us&&... elements) {
|
||||
InitializeElements(data + 1, std::forward<Us>(elements)...);
|
||||
}
|
||||
|
||||
// Default initializes uninitialized array elements.
|
||||
// TODO(kwiberg): Replace with std::uninitialized_default_construct_n() (C++17).
|
||||
template <typename T>
|
||||
void DefaultInitializeElements(T* data, int size) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
// Placement new, because we construct a new object in uninitialized memory.
|
||||
::new (&data[i]) T;
|
||||
}
|
||||
}
|
||||
|
||||
// Copies from source to uninitialized destination. Caller is responsible for
|
||||
// ensuring that there is enough space in `dst_data`.
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user