RealDocs

TArray::ArrayNum

property Core Since 4.0
#include "Containers/Array.h"
Access: protected

Description

Stores the number of elements currently held in the array. Accessed publicly via Num(). Modifying this field directly bypasses all invariant checks and will corrupt the array.

Caveats & Gotchas

  • This field is protected, not private, solely to support TIndirectArray and other engine friend classes. External code must always use Num() to read the count and Add/Remove/Empty/SetNum to modify it.
  • The type SizeType is derived from the allocator and defaults to int32. On 64-bit targets with FDefaultAllocator the range is capped at INT32_MAX elements; exceeding this triggers OnInvalidArrayNum, which terminates the process.

Signature

SizeType ArrayNum

Example

Reading element count via the public API C++
TArray<int32> Numbers = {1, 2, 3};
int32 Count = Numbers.Num(); // Use Num(), not ArrayNum directly
UE_LOG(LogTemp, Log, TEXT("Count: %d"), Count); // 3

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.