From 54fd1b540992f19c650a4533340fb19944c07201 Mon Sep 17 00:00:00 2001 From: alphalex-google Date: Mon, 5 Aug 2024 15:46:22 -0700 Subject: [PATCH] Add "empty()" to vector This is just another `std`-ism that is being added. --- include/flatbuffers/vector.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/flatbuffers/vector.h b/include/flatbuffers/vector.h index cd4858bb8ca..021b3c3fe54 100644 --- a/include/flatbuffers/vector.h +++ b/include/flatbuffers/vector.h @@ -175,6 +175,11 @@ template class Vector { SizeT size() const { return EndianScalar(length_); } + // Returns true if the vector is empty. + // + // This just provides another standardized method that is expected of vectors. + bool empty() const { return size() == 0; } + // Deprecated: use size(). Here for backwards compatibility. FLATBUFFERS_ATTRIBUTE([[deprecated("use size() instead")]]) SizeT Length() const { return size(); }