MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / resize

Method resize

Libraries/Containers/VirtualArray.h:61–84  ·  view source on GitHub ↗

@brief Resizes the stable array, calling constructors or destructors as needed.

Source from the content-addressed store, hash-verified

59
60 /// @brief Resizes the stable array, calling constructors or destructors as needed.
61 [[nodiscard]] bool resize(size_t newSize)
62 {
63 T* items = data();
64 const size_t oldSize = sizeElements;
65 if (newSize < oldSize)
66 {
67 size_t idx = oldSize;
68 do
69 {
70 items[--idx].~T();
71 } while (idx != newSize);
72 }
73 if (not resizeWithoutInitializing(newSize))
74 return false;
75 if (newSize > oldSize)
76 {
77 size_t idx = oldSize;
78 do
79 {
80 placementNew(items[idx++]);
81 } while (idx != newSize);
82 }
83 return true;
84 }
85
86 /// @brief Reserves memory for the stable array without initializing elements.
87 [[nodiscard]] bool reserve(size_t maxNumElements)

Callers

nothing calls this directly

Calls 3

placementNewFunction · 0.85
dataFunction · 0.70

Tested by

no test coverage detected