MCPcopy Create free account
hub / github.com/IntegralPilot/wasm_os / shrink_to_fit

Method shrink_to_fit

stdlib/cpp/vector.hpp:109–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107 size_type capacity() const noexcept { return capacity_; }
108
109 void shrink_to_fit() {
110 if (size_ < capacity_) {
111 T* new_data = allocate(size_);
112
113 if (!new_data) {
114 for(;;);
115 }
116
117 for (size_type i = 0; i < size_; ++i) {
118 new (&new_data[i]) T(std::move(data_[i]));
119 data_[i].~T();
120 }
121
122 deallocate(data_);
123 data_ = new_data;
124 capacity_ = size_;
125 }
126 }
127
128 void reserve(size_type new_capacity) {
129 if (new_capacity > capacity_) {

Callers

nothing calls this directly

Calls 1

moveFunction · 0.85

Tested by

no test coverage detected