From 06b12d55eac124177ed9cec9fd88e0d726dc5515 Mon Sep 17 00:00:00 2001 From: alphalex-google Date: Mon, 19 Aug 2024 17:22:30 -0700 Subject: [PATCH] Add "empty()" to vector (#8369) This is just another `std`-ism that is being added. Co-authored-by: Derek Bailey --- include/flatbuffers/vector.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/flatbuffers/vector.h b/include/flatbuffers/vector.h index cd4858bb8..021b3c3fe 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(); }