Description
Inserts Count zero-initialized elements at Index by shifting existing elements right and then zeroing the new slots with FMemory::Memzero. Useful for POD types where all-zeros is a valid initial state.
Caveats & Gotchas
- • Like InsertUninitialized, no constructor is invoked — only a raw Memzero. Do not use for types with non-trivial constructors (FString, TArray, etc.); use InsertDefaulted() instead.
- • All-zeros is not always a semantically valid state (e.g. a float field that must be non-zero, or a pointer that must be set). Verify that zeroed memory is actually safe for your element type.
Signature
void InsertZeroed(SizeType Index, SizeType Count = 1) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Index | SizeType | Position at which to insert the zeroed elements. | — |
| Count | SizeType | Number of zeroed elements to insert. | 1 |
Return Type
void Example
Insert a zeroed padding slot between structured data C++
TArray<uint8> PacketBuffer;
// ... fill with header bytes ...
// Insert 4 zero padding bytes at offset 8
PacketBuffer.InsertZeroed(8, 4); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?