Add "empty()" to vector (#8369)

This is just another `std`-ism that is being added.

Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
alphalex-google
2024-08-19 17:22:30 -07:00
committed by GitHub
parent baddf90599
commit 06b12d55ea

View File

@@ -175,6 +175,11 @@ template<typename T, typename SizeT = uoffset_t> 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(); }