RealDocs

TArray::IsEmpty

function Core Since 4.0
#include "Containers/Array.h"
Access: public

Description

Returns true if the array contains no elements. Equivalent to Num() == 0 but more expressive as a guard clause. Does not consider allocated capacity.

Signature

bool IsEmpty() const

Return Type

bool

Caveats & Gotchas

  • An array can be empty but still have allocated capacity (e.g. after Reset()). IsEmpty() reflects logical emptiness only, not memory state.
  • Prefer IsEmpty() over Num() == 0 in condition checks — it signals intent more clearly and is equally fast.
  • Not the same as checking the pointer is valid — even an array declared on the stack is always a valid object. IsEmpty() purely tests element count.

Example

Early-out and conditional logic C++
if (PendingActors.IsEmpty())
{
    return; // nothing to process
}
for (AActor* Actor : PendingActors)
{
    ProcessActor(Actor);
}

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.