diff options
author | Vladimir Glavnyy <31897320+vglavnyy@users.noreply.github.com> | 2019-01-25 04:33:19 +0700 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2019-01-24 13:33:19 -0800 |
commit | fcacb46d01c1d3c9b08124f36dd890e1dfeadb0a (patch) | |
tree | 6f83d80ba58f86a8f9f0fbe781e8bccddadc759c /include | |
parent | 3f388ec7471b39826ce44e00d77bc40a6159b045 (diff) | |
download | flatbuffers-fcacb46d01c1d3c9b08124f36dd890e1dfeadb0a.tar.gz flatbuffers-fcacb46d01c1d3c9b08124f36dd890e1dfeadb0a.tar.bz2 flatbuffers-fcacb46d01c1d3c9b08124f36dd890e1dfeadb0a.zip |
Replace deprecated Vector::Length() with Vector::size() (#5131)
- enable FLATBUFFERS_ATTRIBUTE if C++17 or higher
Diffstat (limited to 'include')
-rw-r--r-- | include/flatbuffers/base.h | 4 | ||||
-rw-r--r-- | include/flatbuffers/flatbuffers.h | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h index 038b5ab0..ad474bb7 100644 --- a/include/flatbuffers/base.h +++ b/include/flatbuffers/base.h @@ -235,11 +235,11 @@ template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) { return !!t; } -// Enable of std:c++17 or higher. +// Enable C++ attribute [[]] if std:c++17 or higher. #if (defined(__cplusplus) && (__cplusplus >= 201703L)) || \ (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)) // All attributes unknown to an implementation are ignored without causing an error. - #define FLATBUFFERS_ATTRIBUTE(attr) // [[attr]] - will be enabled in a future release + #define FLATBUFFERS_ATTRIBUTE(attr) [[attr]] #else #define FLATBUFFERS_ATTRIBUTE(attr) #endif diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index 4a292f1d..062c7f5b 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -390,7 +390,7 @@ const Vector<Offset<T>> *VectorCast(const Vector<Offset<U>> *ptr) { // Convenient helper function to get the length of any vector, regardless // of whether it is null or not (the field is not set). template<typename T> static inline size_t VectorLength(const Vector<T> *v) { - return v ? v->Length() : 0; + return v ? v->size() : 0; } // Lexicographically compare two strings (possibly containing nulls), and @@ -403,12 +403,12 @@ static inline bool StringLessThan(const char *a_data, uoffset_t a_size, struct String : public Vector<char> { const char *c_str() const { return reinterpret_cast<const char *>(Data()); } - std::string str() const { return std::string(c_str(), Length()); } + std::string str() const { return std::string(c_str(), size()); } // clang-format off #ifdef FLATBUFFERS_HAS_STRING_VIEW flatbuffers::string_view string_view() const { - return flatbuffers::string_view(c_str(), Length()); + return flatbuffers::string_view(c_str(), size()); } #endif // FLATBUFFERS_HAS_STRING_VIEW // clang-format on @@ -1340,7 +1340,7 @@ class FlatBufferBuilder { /// @param[in] str A const pointer to a `String` struct to add to the buffer. /// @return Returns the offset in the buffer where the string starts Offset<String> CreateString(const String *str) { - return str ? CreateString(str->c_str(), str->Length()) : 0; + return str ? CreateString(str->c_str(), str->size()) : 0; } /// @brief Store a string in the buffer, which can contain any binary data. @@ -1400,7 +1400,7 @@ class FlatBufferBuilder { /// @param[in] str A const pointer to a `String` struct to add to the buffer. /// @return Returns the offset in the buffer where the string starts Offset<String> CreateSharedString(const String *str) { - return CreateSharedString(str->c_str(), str->Length()); + return CreateSharedString(str->c_str(), str->size()); } /// @cond FLATBUFFERS_INTERNAL |