diff --git a/android/app/build.gradle b/android/app/build.gradle index f72f21f0b8d..dba6624f25d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -101,16 +101,6 @@ android { flavorDimensions "stl-variant" productFlavors { - stlport { - dimension "stl-variant" - applicationIdSuffix ".stlport" - versionNameSuffix "-stlport" - externalNativeBuild { - ndkBuild { - arguments "APP_STL=stlport_static" - } - } - } gnustl { dimension "stl-variant" applicationIdSuffix ".gnustl" diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h index f1eb312f380..15c89b17f06 100644 --- a/include/flatbuffers/base.h +++ b/include/flatbuffers/base.h @@ -50,10 +50,6 @@ #include #endif -#ifdef _STLPORT_VERSION - #define FLATBUFFERS_CPP98_STL -#endif - #ifdef __ANDROID__ #include #endif diff --git a/include/flatbuffers/detached_buffer.h b/include/flatbuffers/detached_buffer.h index 9d000293808..760a0884535 100644 --- a/include/flatbuffers/detached_buffer.h +++ b/include/flatbuffers/detached_buffer.h @@ -45,9 +45,6 @@ class DetachedBuffer { cur_(cur), size_(sz) {} - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on DetachedBuffer(DetachedBuffer &&other) : allocator_(other.allocator_), own_allocator_(other.own_allocator_), @@ -57,13 +54,7 @@ class DetachedBuffer { size_(other.size_) { other.reset(); } - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on DetachedBuffer &operator=(DetachedBuffer &&other) { if (this == &other) return *this; @@ -80,9 +71,6 @@ class DetachedBuffer { return *this; } - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on ~DetachedBuffer() { destroy(); } @@ -92,16 +80,10 @@ class DetachedBuffer { size_t size() const { return size_; } - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on // These may change access mode, leave these at end of public section FLATBUFFERS_DELETE_FUNC(DetachedBuffer(const DetachedBuffer &other)); FLATBUFFERS_DELETE_FUNC( DetachedBuffer &operator=(const DetachedBuffer &other)); - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on protected: Allocator *allocator_; @@ -129,4 +111,4 @@ class DetachedBuffer { } // namespace flatbuffers -#endif // FLATBUFFERS_DETACHED_BUFFER_H_ \ No newline at end of file +#endif // FLATBUFFERS_DETACHED_BUFFER_H_ diff --git a/include/flatbuffers/flatbuffer_builder.h b/include/flatbuffers/flatbuffer_builder.h index 5aa358f8ee3..324b0c33c84 100644 --- a/include/flatbuffers/flatbuffer_builder.h +++ b/include/flatbuffers/flatbuffer_builder.h @@ -31,9 +31,7 @@ #include "flatbuffers/vector_downward.h" #include "flatbuffers/verifier.h" -#ifndef FLATBUFFERS_CPP98_STL -# include -#endif +#include namespace flatbuffers { @@ -96,13 +94,8 @@ class FlatBufferBuilder { EndianCheck(); } - // clang-format off /// @brief Move constructor for FlatBufferBuilder. - #if !defined(FLATBUFFERS_CPP98_STL) FlatBufferBuilder(FlatBufferBuilder &&other) - #else - FlatBufferBuilder(FlatBufferBuilder &other) - #endif // #if !defined(FLATBUFFERS_CPP98_STL) : buf_(1024, nullptr, false, AlignOf()), num_field_loc(0), max_voffset_(0), @@ -117,11 +110,7 @@ class FlatBufferBuilder { // Lack of delegating constructors in vs2010 makes it more verbose than needed. Swap(other); } - // clang-format on - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on /// @brief Move assignment operator for FlatBufferBuilder. FlatBufferBuilder &operator=(FlatBufferBuilder &&other) { // Move construct a temporary and swap idiom @@ -129,9 +118,6 @@ class FlatBufferBuilder { Swap(temp); return *this; } - // clang-format off - #endif // defined(FLATBUFFERS_CPP98_STL) - // clang-format on void Swap(FlatBufferBuilder &other) { using std::swap; @@ -683,8 +669,6 @@ class FlatBufferBuilder { return Offset>(EndVector(v.size())); } - // clang-format off - #ifndef FLATBUFFERS_CPP98_STL /// @brief Serialize values returned by a function into a FlatBuffer `vector`. /// This is a convenience function that takes care of iteration for you. /// @tparam T The data type of the `std::vector` elements. @@ -699,8 +683,6 @@ class FlatBufferBuilder { for (size_t i = 0; i < vector_size; i++) elems[i] = f(i); return CreateVector(elems); } - #endif // FLATBUFFERS_CPP98_STL - // clang-format on /// @brief Serialize values returned by a function into a FlatBuffer `vector`. /// This is a convenience function that takes care of iteration for you. This @@ -811,8 +793,6 @@ class FlatBufferBuilder { return CreateVectorOfNativeStructs(v, len, Pack); } - // clang-format off - #ifndef FLATBUFFERS_CPP98_STL /// @brief Serialize an array of structs into a FlatBuffer `vector`. /// @tparam T The data type of the struct array elements. /// @param[in] filler A function that takes the current iteration 0..vector_size-1 @@ -830,8 +810,6 @@ class FlatBufferBuilder { } return EndVectorOfStructs(vector_size); } - #endif - // clang-format on /// @brief Serialize an array of structs into a FlatBuffer `vector`. /// @tparam T The data type of the struct array elements. @@ -1198,4 +1176,4 @@ void FlatBufferBuilder::Required(Offset table, voffset_t field) { } // namespace flatbuffers -#endif // FLATBUFFERS_VECTOR_DOWNWARD_H_ \ No newline at end of file +#endif // FLATBUFFERS_VECTOR_DOWNWARD_H_ diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index 509edd89b0b..306401dbd6d 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -92,16 +92,9 @@ struct NativeTable {}; /// if you wish. The resolver does the opposite lookup, for when the object /// is being serialized again. typedef uint64_t hash_value_t; -// clang-format off -#ifdef FLATBUFFERS_CPP98_STL - typedef void (*resolver_function_t)(void **pointer_adr, hash_value_t hash); - typedef hash_value_t (*rehasher_function_t)(void *pointer); -#else - typedef std::function - resolver_function_t; - typedef std::function rehasher_function_t; -#endif -// clang-format on +typedef std::function + resolver_function_t; +typedef std::function rehasher_function_t; // Helper function to test if a field is present, using any of the field // enums in the generated code. diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h index 6ac698d3286..3c85b7931a6 100644 --- a/include/flatbuffers/flexbuffers.h +++ b/include/flatbuffers/flexbuffers.h @@ -873,7 +873,7 @@ inline Reference GetRoot(const uint8_t *buffer, size_t size) { } inline Reference GetRoot(const std::vector &buffer) { - return GetRoot(flatbuffers::vector_data(buffer), buffer.size()); + return GetRoot(buffer.data(), buffer.size()); } // Flags that configure how the Builder behaves. @@ -1069,7 +1069,7 @@ class Builder FLATBUFFERS_FINAL_CLASS { return CreateBlob(data, len, 0, FBT_BLOB); } size_t Blob(const std::vector &v) { - return CreateBlob(flatbuffers::vector_data(v), v.size(), 0, FBT_BLOB); + return CreateBlob(v.data(), v.size(), 0, FBT_BLOB); } void Blob(const char *key, const void *data, size_t len) { @@ -1131,14 +1131,11 @@ class Builder FLATBUFFERS_FINAL_CLASS { // step automatically when appliccable, and encourage people to write in // sorted fashion. // std::sort is typically already a lot faster on sorted data though. - auto dict = - reinterpret_cast(flatbuffers::vector_data(stack_) + start); + auto dict = reinterpret_cast(stack_.data() + start); std::sort(dict, dict + len, [&](const TwoValue &a, const TwoValue &b) -> bool { - auto as = reinterpret_cast( - flatbuffers::vector_data(buf_) + a.key.u_); - auto bs = reinterpret_cast( - flatbuffers::vector_data(buf_) + b.key.u_); + auto as = reinterpret_cast(buf_.data() + a.key.u_); + auto bs = reinterpret_cast(buf_.data() + b.key.u_); auto comp = strcmp(as, bs); // We want to disallow duplicate keys, since this results in a // map where values cannot be found. @@ -1205,7 +1202,7 @@ class Builder FLATBUFFERS_FINAL_CLASS { Vector(elems, len); } template void Vector(const std::vector &vec) { - Vector(flatbuffers::vector_data(vec), vec.size()); + Vector(vec.data(), vec.size()); } template size_t TypedVector(F f) { @@ -1607,10 +1604,8 @@ class Builder FLATBUFFERS_FINAL_CLASS { struct KeyOffsetCompare { explicit KeyOffsetCompare(const std::vector &buf) : buf_(&buf) {} bool operator()(size_t a, size_t b) const { - auto stra = - reinterpret_cast(flatbuffers::vector_data(*buf_) + a); - auto strb = - reinterpret_cast(flatbuffers::vector_data(*buf_) + b); + auto stra = reinterpret_cast(buf_->data() + a); + auto strb = reinterpret_cast(buf_->data() + b); return strcmp(stra, strb) < 0; } const std::vector *buf_; @@ -1621,10 +1616,8 @@ class Builder FLATBUFFERS_FINAL_CLASS { explicit StringOffsetCompare(const std::vector &buf) : buf_(&buf) {} bool operator()(const StringOffset &a, const StringOffset &b) const { - auto stra = reinterpret_cast( - flatbuffers::vector_data(*buf_) + a.first); - auto strb = reinterpret_cast( - flatbuffers::vector_data(*buf_) + b.first); + auto stra = reinterpret_cast(buf_->data() + a.first); + auto strb = reinterpret_cast(buf_->data() + b.first); return strncmp(stra, strb, (std::min)(a.second, b.second) + 1) < 0; } const std::vector *buf_; diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h index 3ee02a95f99..bb08806ecee 100644 --- a/include/flatbuffers/idl.h +++ b/include/flatbuffers/idl.h @@ -27,9 +27,7 @@ #include "flatbuffers/hash.h" #include "flatbuffers/reflection.h" -#if !defined(FLATBUFFERS_CPP98_STL) -# include -#endif // !defined(FLATBUFFERS_CPP98_STL) +#include // This file defines the data types representing a parsed IDL (Interface // Definition Language) / schema file. @@ -207,7 +205,7 @@ template class SymbolTable { } bool Add(const std::string &name, T *e) { - vector_emplace_back(&vec, e); + vec.emplace_back(e); auto it = dict.find(name); if (it != dict.end()) return true; dict[name] = e; diff --git a/include/flatbuffers/reflection.h b/include/flatbuffers/reflection.h index fa2cf31fad0..cb3ec9a0f0f 100644 --- a/include/flatbuffers/reflection.h +++ b/include/flatbuffers/reflection.h @@ -379,12 +379,12 @@ template class pointer_inside_vector { public: pointer_inside_vector(T *ptr, std::vector &vec) : offset_(reinterpret_cast(ptr) - - reinterpret_cast(flatbuffers::vector_data(vec))), + reinterpret_cast(vec.data())), vec_(vec) {} T *operator*() const { - return reinterpret_cast( - reinterpret_cast(flatbuffers::vector_data(vec_)) + offset_); + return reinterpret_cast(reinterpret_cast(vec_.data()) + + offset_); } T *operator->() const { return operator*(); } diff --git a/include/flatbuffers/registry.h b/include/flatbuffers/registry.h index 563d6206457..e8bb8f5e32b 100644 --- a/include/flatbuffers/registry.h +++ b/include/flatbuffers/registry.h @@ -104,7 +104,7 @@ class Registry { } // Parse schema. parser->opts = opts_; - if (!parser->Parse(schematext.c_str(), vector_data(include_paths_), + if (!parser->Parse(schematext.c_str(), include_paths_.data(), schema.path_.c_str())) { lasterror_ = parser->error_; return false; diff --git a/include/flatbuffers/stl_emulation.h b/include/flatbuffers/stl_emulation.h index 2697a0a8a4c..75d13b29ced 100644 --- a/include/flatbuffers/stl_emulation.h +++ b/include/flatbuffers/stl_emulation.h @@ -26,14 +26,6 @@ #include #include -#if defined(_STLPORT_VERSION) && !defined(FLATBUFFERS_CPP98_STL) - #define FLATBUFFERS_CPP98_STL -#endif // defined(_STLPORT_VERSION) && !defined(FLATBUFFERS_CPP98_STL) - -#if defined(FLATBUFFERS_CPP98_STL) - #include -#endif // defined(FLATBUFFERS_CPP98_STL) - // Detect C++17 compatible compiler. // __cplusplus >= 201703L - a compiler has support of 'static inline' variables. #if defined(FLATBUFFERS_USE_STD_OPTIONAL) \ @@ -55,7 +47,7 @@ #endif #else // Disable non-trivial ctors if FLATBUFFERS_SPAN_MINIMAL defined. - #if !defined(FLATBUFFERS_TEMPLATES_ALIASES) || defined(FLATBUFFERS_CPP98_STL) + #if !defined(FLATBUFFERS_TEMPLATES_ALIASES) #define FLATBUFFERS_SPAN_MINIMAL #else // Enable implicit construction of a span from a std::array. @@ -63,139 +55,32 @@ #endif #endif // defined(FLATBUFFERS_USE_STD_SPAN) -// This header provides backwards compatibility for C++98 STLs like stlport. +// This header provides backwards compatibility for older versions of the STL. namespace flatbuffers { -// Retrieve ::back() from a string in a way that is compatible with pre C++11 -// STLs (e.g stlport). -inline char& string_back(std::string &value) { - return value[value.length() - 1]; -} - -inline char string_back(const std::string &value) { - return value[value.length() - 1]; -} - -// Helper method that retrieves ::data() from a vector in a way that is -// compatible with pre C++11 STLs (e.g stlport). -template inline T *vector_data(std::vector &vector) { - // In some debug environments, operator[] does bounds checking, so &vector[0] - // can't be used. - return vector.empty() ? nullptr : &vector[0]; -} - -template inline const T *vector_data( - const std::vector &vector) { - return vector.empty() ? nullptr : &vector[0]; -} - -template -inline void vector_emplace_back(std::vector *vector, V &&data) { - #if defined(FLATBUFFERS_CPP98_STL) - vector->push_back(data); - #else - vector->emplace_back(std::forward(data)); - #endif // defined(FLATBUFFERS_CPP98_STL) -} - -#ifndef FLATBUFFERS_CPP98_STL - #if defined(FLATBUFFERS_TEMPLATES_ALIASES) - template - using numeric_limits = std::numeric_limits; - #else - template class numeric_limits : - public std::numeric_limits {}; - #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) +#if defined(FLATBUFFERS_TEMPLATES_ALIASES) + template + using numeric_limits = std::numeric_limits; #else template class numeric_limits : - public std::numeric_limits { - public: - // Android NDK fix. - static T lowest() { - return std::numeric_limits::min(); - } - }; - - template <> class numeric_limits : - public std::numeric_limits { - public: - static float lowest() { return -FLT_MAX; } - }; - - template <> class numeric_limits : - public std::numeric_limits { - public: - static double lowest() { return -DBL_MAX; } - }; - - template <> class numeric_limits { - public: - static unsigned long long min() { return 0ULL; } - static unsigned long long max() { return ~0ULL; } - static unsigned long long lowest() { - return numeric_limits::min(); - } - }; - - template <> class numeric_limits { - public: - static long long min() { - return static_cast(1ULL << ((sizeof(long long) << 3) - 1)); - } - static long long max() { - return static_cast( - (1ULL << ((sizeof(long long) << 3) - 1)) - 1); - } - static long long lowest() { - return numeric_limits::min(); - } - }; -#endif // FLATBUFFERS_CPP98_STL + public std::numeric_limits {}; +#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) #if defined(FLATBUFFERS_TEMPLATES_ALIASES) - #ifndef FLATBUFFERS_CPP98_STL - template using is_scalar = std::is_scalar; - template using is_same = std::is_same; - template using is_floating_point = std::is_floating_point; - template using is_unsigned = std::is_unsigned; - template using is_enum = std::is_enum; - template using make_unsigned = std::make_unsigned; - template - using conditional = std::conditional; - template - using integral_constant = std::integral_constant; - template - using bool_constant = integral_constant; - using true_type = std::true_type; - using false_type = std::false_type; - #else - // Map C++ TR1 templates defined by stlport. - template using is_scalar = std::tr1::is_scalar; - template using is_same = std::tr1::is_same; - template using is_floating_point = - std::tr1::is_floating_point; - template using is_unsigned = std::tr1::is_unsigned; - template using is_enum = std::tr1::is_enum; - // Android NDK doesn't have std::make_unsigned or std::tr1::make_unsigned. - template struct make_unsigned { - static_assert(is_unsigned::value, "Specialization not implemented!"); - using type = T; - }; - template<> struct make_unsigned { using type = unsigned char; }; - template<> struct make_unsigned { using type = unsigned short; }; - template<> struct make_unsigned { using type = unsigned int; }; - template<> struct make_unsigned { using type = unsigned long; }; - template<> - struct make_unsigned { using type = unsigned long long; }; - template - using conditional = std::tr1::conditional; - template - using integral_constant = std::tr1::integral_constant; - template - using bool_constant = integral_constant; - using true_type = bool_constant; - using false_type = bool_constant; - #endif // !FLATBUFFERS_CPP98_STL + template using is_scalar = std::is_scalar; + template using is_same = std::is_same; + template using is_floating_point = std::is_floating_point; + template using is_unsigned = std::is_unsigned; + template using is_enum = std::is_enum; + template using make_unsigned = std::make_unsigned; + template + using conditional = std::conditional; + template + using integral_constant = std::integral_constant; + template + using bool_constant = integral_constant; + using true_type = std::true_type; + using false_type = std::false_type; #else // MSVC 2010 doesn't support C++11 aliases. template struct is_scalar : public std::is_scalar {}; @@ -215,124 +100,33 @@ inline void vector_emplace_back(std::vector *vector, V &&data) { typedef bool_constant false_type; #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) -#ifndef FLATBUFFERS_CPP98_STL - #if defined(FLATBUFFERS_TEMPLATES_ALIASES) - template using unique_ptr = std::unique_ptr; - #else - // MSVC 2010 doesn't support C++11 aliases. - // We're manually "aliasing" the class here as we want to bring unique_ptr - // into the flatbuffers namespace. We have unique_ptr in the flatbuffers - // namespace we have a completely independent implementation (see below) - // for C++98 STL implementations. - template class unique_ptr : public std::unique_ptr { - public: - unique_ptr() {} - explicit unique_ptr(T* p) : std::unique_ptr(p) {} - unique_ptr(std::unique_ptr&& u) { *this = std::move(u); } - unique_ptr(unique_ptr&& u) { *this = std::move(u); } - unique_ptr& operator=(std::unique_ptr&& u) { - std::unique_ptr::reset(u.release()); - return *this; - } - unique_ptr& operator=(unique_ptr&& u) { - std::unique_ptr::reset(u.release()); - return *this; - } - unique_ptr& operator=(T* p) { - return std::unique_ptr::operator=(p); - } - }; - #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) +#if defined(FLATBUFFERS_TEMPLATES_ALIASES) + template using unique_ptr = std::unique_ptr; #else - // Very limited implementation of unique_ptr. - // This is provided simply to allow the C++ code generated from the default - // settings to function in C++98 environments with no modifications. - template class unique_ptr { - public: - typedef T element_type; - - unique_ptr() : ptr_(nullptr) {} - explicit unique_ptr(T* p) : ptr_(p) {} - unique_ptr(unique_ptr&& u) : ptr_(nullptr) { reset(u.release()); } - unique_ptr(const unique_ptr& u) : ptr_(nullptr) { - reset(const_cast(&u)->release()); - } - ~unique_ptr() { reset(); } - - unique_ptr& operator=(const unique_ptr& u) { - reset(const_cast(&u)->release()); + // MSVC 2010 doesn't support C++11 aliases. + // We're manually "aliasing" the class here as we want to bring unique_ptr + // into the flatbuffers namespace. We have unique_ptr in the flatbuffers + // namespace we have a completely independent implementation (see below) + // for C++98 STL implementations. + template class unique_ptr : public std::unique_ptr { + public: + unique_ptr() {} + explicit unique_ptr(T* p) : std::unique_ptr(p) {} + unique_ptr(std::unique_ptr&& u) { *this = std::move(u); } + unique_ptr(unique_ptr&& u) { *this = std::move(u); } + unique_ptr& operator=(std::unique_ptr&& u) { + std::unique_ptr::reset(u.release()); return *this; } - unique_ptr& operator=(unique_ptr&& u) { - reset(u.release()); + std::unique_ptr::reset(u.release()); return *this; } - unique_ptr& operator=(T* p) { - reset(p); - return *this; - } - - const T& operator*() const { return *ptr_; } - T* operator->() const { return ptr_; } - T* get() const noexcept { return ptr_; } - explicit operator bool() const { return ptr_ != nullptr; } - - // modifiers - T* release() { - T* value = ptr_; - ptr_ = nullptr; - return value; - } - - void reset(T* p = nullptr) { - T* value = ptr_; - ptr_ = p; - if (value) delete value; - } - - void swap(unique_ptr& u) { - T* temp_ptr = ptr_; - ptr_ = u.ptr_; - u.ptr_ = temp_ptr; + return std::unique_ptr::operator=(p); } - - private: - T* ptr_; }; - - template bool operator==(const unique_ptr& x, - const unique_ptr& y) { - return x.get() == y.get(); - } - - template bool operator==(const unique_ptr& x, - const D* y) { - return static_cast(x.get()) == y; - } - - template bool operator==(const unique_ptr& x, intptr_t y) { - return reinterpret_cast(x.get()) == y; - } - - template bool operator!=(const unique_ptr& x, decltype(nullptr)) { - return !!x; - } - - template bool operator!=(decltype(nullptr), const unique_ptr& x) { - return !!x; - } - - template bool operator==(const unique_ptr& x, decltype(nullptr)) { - return !x; - } - - template bool operator==(decltype(nullptr), const unique_ptr& x) { - return !x; - } - -#endif // !FLATBUFFERS_CPP98_STL +#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) #ifdef FLATBUFFERS_USE_STD_OPTIONAL template diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h index edbee649569..020a0607c4a 100644 --- a/include/flatbuffers/util.h +++ b/include/flatbuffers/util.h @@ -145,20 +145,6 @@ template<> inline std::string NumToString(unsigned char t) { template<> inline std::string NumToString(char t) { return NumToString(static_cast(t)); } -#if defined(FLATBUFFERS_CPP98_STL) -template<> inline std::string NumToString(long long t) { - char buf[21]; // (log((1 << 63) - 1) / log(10)) + 2 - snprintf(buf, sizeof(buf), "%lld", t); - return std::string(buf); -} - -template<> -inline std::string NumToString(unsigned long long t) { - char buf[22]; // (log((1 << 63) - 1) / log(10)) + 1 - snprintf(buf, sizeof(buf), "%llu", t); - return std::string(buf); -} -#endif // defined(FLATBUFFERS_CPP98_STL) // Special versions for floats/doubles. template std::string FloatToString(T t, int precision) { diff --git a/include/flatbuffers/vector.h b/include/flatbuffers/vector.h index 820c59c2764..f8a5d88e86b 100644 --- a/include/flatbuffers/vector.h +++ b/include/flatbuffers/vector.h @@ -43,14 +43,10 @@ template struct VectorIterator { return *this; } - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) VectorIterator &operator=(VectorIterator &&other) { data_ = other.data_; return *this; } - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on bool operator==(const VectorIterator &other) const { return data_ == other.data_; @@ -351,7 +347,6 @@ class VectorOfAny { VectorOfAny &operator=(const VectorOfAny &); }; -#ifndef FLATBUFFERS_CPP98_STL template Vector> *VectorCast(Vector> *ptr) { static_assert(std::is_base_of::value, "Unrelated types"); @@ -363,7 +358,6 @@ const Vector> *VectorCast(const Vector> *ptr) { static_assert(std::is_base_of::value, "Unrelated types"); return reinterpret_cast> *>(ptr); } -#endif // Convenient helper function to get the length of any vector, regardless // of whether it is null or not (the field is not set). diff --git a/include/flatbuffers/vector_downward.h b/include/flatbuffers/vector_downward.h index d507134c83a..8088b10c569 100644 --- a/include/flatbuffers/vector_downward.h +++ b/include/flatbuffers/vector_downward.h @@ -42,12 +42,7 @@ class vector_downward { cur_(nullptr), scratch_(nullptr) {} - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) vector_downward(vector_downward &&other) - #else - vector_downward(vector_downward &other) - #endif // defined(FLATBUFFERS_CPP98_STL) // clang-format on : allocator_(other.allocator_), own_allocator_(other.own_allocator_), @@ -67,18 +62,12 @@ class vector_downward { other.scratch_ = nullptr; } - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on vector_downward &operator=(vector_downward &&other) { // Move construct a temporary and swap idiom vector_downward temp(std::move(other)); swap(temp); return *this; } - // clang-format off - #endif // defined(FLATBUFFERS_CPP98_STL) - // clang-format on ~vector_downward() { clear_buffer(); @@ -269,4 +258,4 @@ class vector_downward { } // namespace flatbuffers -#endif // FLATBUFFERS_VECTOR_DOWNWARD_H_ \ No newline at end of file +#endif // FLATBUFFERS_VECTOR_DOWNWARD_H_ diff --git a/samples/monster_generated.h b/samples/monster_generated.h index 50c1ff157ab..df956e13b67 100644 --- a/samples/monster_generated.h +++ b/samples/monster_generated.h @@ -120,7 +120,6 @@ struct EquipmentUnion { void Reset(); -#ifndef FLATBUFFERS_CPP98_STL template void Set(T&& val) { using RT = typename std::remove_reference::type; @@ -130,7 +129,6 @@ struct EquipmentUnion { value = new RT(std::forward(val)); } } -#endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, Equipment type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; diff --git a/src/code_generators.cpp b/src/code_generators.cpp index aa77e1a34c5..38e3b81c651 100644 --- a/src/code_generators.cpp +++ b/src/code_generators.cpp @@ -60,7 +60,7 @@ void CodeWriter::operator+=(std::string text) { // Update the text to everything after the }}. text = text.substr(end + 2); } - if (!text.empty() && string_back(text) == '\\') { + if (!text.empty() && text.back() == '\\') { text.pop_back(); ignore_ident_ = true; stream_ << text; diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index e09bad2cbf2..4a37eab295e 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -1339,7 +1339,6 @@ class CppGenerator : public BaseGenerator { code_ += " void Reset();"; code_ += ""; if (!enum_def.uses_multiple_type_instances) { - code_ += "#ifndef FLATBUFFERS_CPP98_STL"; code_ += " template "; code_ += " void Set(T&& val) {"; code_ += " using RT = typename std::remove_reference::type;"; @@ -1350,7 +1349,6 @@ class CppGenerator : public BaseGenerator { code_ += " value = new RT(std::forward(val));"; code_ += " }"; code_ += " }"; - code_ += "#endif // FLATBUFFERS_CPP98_STL"; code_ += ""; } code_ += " " + UnionUnPackSignature(enum_def, true) + ";"; diff --git a/src/idl_gen_csharp.cpp b/src/idl_gen_csharp.cpp index d481a1920ec..dd023bc7aab 100644 --- a/src/idl_gen_csharp.cpp +++ b/src/idl_gen_csharp.cpp @@ -23,10 +23,6 @@ #include "flatbuffers/idl.h" #include "flatbuffers/util.h" -#if defined(FLATBUFFERS_CPP98_STL) -# include -#endif // defined(FLATBUFFERS_CPP98_STL) - namespace flatbuffers { static TypedFloatConstantGenerator CSharpFloatGen("Double.", "Single.", "NaN", diff --git a/src/idl_gen_java.cpp b/src/idl_gen_java.cpp index 0befb184a32..01dce4a3b4e 100644 --- a/src/idl_gen_java.cpp +++ b/src/idl_gen_java.cpp @@ -21,10 +21,6 @@ #include "flatbuffers/idl.h" #include "flatbuffers/util.h" -#if defined(FLATBUFFERS_CPP98_STL) -# include -#endif // defined(FLATBUFFERS_CPP98_STL) - namespace flatbuffers { namespace java { diff --git a/src/idl_gen_kotlin.cpp b/src/idl_gen_kotlin.cpp index 511e1b7c7b9..3c9377f2c9b 100644 --- a/src/idl_gen_kotlin.cpp +++ b/src/idl_gen_kotlin.cpp @@ -23,9 +23,6 @@ #include "flatbuffers/flatbuffers.h" #include "flatbuffers/idl.h" #include "flatbuffers/util.h" -#if defined(FLATBUFFERS_CPP98_STL) -# include -#endif // defined(FLATBUFFERS_CPP98_STL) namespace flatbuffers { diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index 328d8dcb35a..4e18e192ad6 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -1627,7 +1627,7 @@ CheckedError Parser::ParseArray(Value &array) { auto length = array.type.fixed_length; uoffset_t count = 0; auto err = ParseVectorDelimiters(count, [&](uoffset_t &) -> CheckedError { - vector_emplace_back(&stack, Value()); + stack.emplace_back(Value()); auto &val = stack.back(); val.type = type; if (IsStruct(type)) { @@ -3319,7 +3319,7 @@ CheckedError Parser::DoParse(const char *source, const char **include_paths, ECHECK(ParseProtoDecl()); } else if (IsIdent("native_include")) { NEXT(); - vector_emplace_back(&native_included_files_, attribute_); + native_included_files_.emplace_back(attribute_); EXPECT(kTokenStringConstant); EXPECT(';'); } else if (IsIdent("include") || (opts.proto_mode && IsIdent("import"))) { diff --git a/src/reflection.cpp b/src/reflection.cpp index 2dedcb4f18d..8ab0dc344c5 100644 --- a/src/reflection.cpp +++ b/src/reflection.cpp @@ -180,7 +180,7 @@ class ResizeContext { std::vector *flatbuf, const reflection::Object *root_table = nullptr) : schema_(schema), - startptr_(vector_data(*flatbuf) + start), + startptr_(flatbuf->data() + start), delta_(delta), buf_(*flatbuf), dag_check_(flatbuf->size() / sizeof(uoffset_t), false) { @@ -188,8 +188,8 @@ class ResizeContext { delta_ = (delta_ + mask) & ~mask; if (!delta_) return; // We can't shrink by less than largest_scalar_t. // Now change all the offsets by delta_. - auto root = GetAnyRoot(vector_data(buf_)); - Straddle(vector_data(buf_), root, vector_data(buf_)); + auto root = GetAnyRoot(buf_.data()); + Straddle(buf_.data(), root, buf_.data()); ResizeTable(root_table ? *root_table : *schema.root_table(), root); // We can now add or remove bytes at start. if (delta_ > 0) @@ -217,7 +217,7 @@ class ResizeContext { // will straddle and which won't. uint8_t &DagCheck(const void *offsetloc) { auto dag_idx = reinterpret_cast(offsetloc) - - reinterpret_cast(vector_data(buf_)); + reinterpret_cast(buf_.data()); return dag_check_[dag_idx]; } @@ -309,19 +309,19 @@ void SetString(const reflection::Schema &schema, const std::string &val, const reflection::Object *root_table) { auto delta = static_cast(val.size()) - static_cast(str->size()); auto str_start = static_cast( - reinterpret_cast(str) - vector_data(*flatbuf)); + reinterpret_cast(str) - flatbuf->data()); auto start = str_start + static_cast(sizeof(uoffset_t)); if (delta) { // Clear the old string, since we don't want parts of it remaining. - memset(vector_data(*flatbuf) + start, 0, str->size()); + memset(flatbuf->data() + start, 0, str->size()); // Different size, we must expand (or contract). ResizeContext(schema, start, delta, flatbuf, root_table); // Set the new length. - WriteScalar(vector_data(*flatbuf) + str_start, + WriteScalar(flatbuf->data() + str_start, static_cast(val.size())); } // Copy new data. Safe because we created the right amount of space. - memcpy(vector_data(*flatbuf) + start, val.c_str(), val.size() + 1); + memcpy(flatbuf->data() + start, val.c_str(), val.size() + 1); } uint8_t *ResizeAnyVector(const reflection::Schema &schema, uoffset_t newsize, @@ -331,7 +331,7 @@ uint8_t *ResizeAnyVector(const reflection::Schema &schema, uoffset_t newsize, auto delta_elem = static_cast(newsize) - static_cast(num_elems); auto delta_bytes = delta_elem * static_cast(elem_size); auto vec_start = - reinterpret_cast(vec) - vector_data(*flatbuf); + reinterpret_cast(vec) - flatbuf->data(); auto start = static_cast(vec_start + sizeof(uoffset_t) + elem_size * num_elems); if (delta_bytes) { @@ -339,16 +339,16 @@ uint8_t *ResizeAnyVector(const reflection::Schema &schema, uoffset_t newsize, // Clear elements we're throwing away, since some might remain in the // buffer. auto size_clear = -delta_elem * elem_size; - memset(vector_data(*flatbuf) + start - size_clear, 0, size_clear); + memset(flatbuf->data() + start - size_clear, 0, size_clear); } ResizeContext(schema, start, delta_bytes, flatbuf, root_table); - WriteScalar(vector_data(*flatbuf) + vec_start, newsize); // Length field. + WriteScalar(flatbuf->data() + vec_start, newsize); // Length field. // Set new elements to 0.. this can be overwritten by the caller. if (delta_elem > 0) { - memset(vector_data(*flatbuf) + start, 0, delta_elem * elem_size); + memset(flatbuf->data() + start, 0, delta_elem * elem_size); } } - return vector_data(*flatbuf) + start; + return flatbuf->data() + start; } const uint8_t *AddFlatBuffer(std::vector &flatbuf, @@ -363,7 +363,7 @@ const uint8_t *AddFlatBuffer(std::vector &flatbuf, // Insert the entire FlatBuffer minus the root pointer. flatbuf.insert(flatbuf.end(), newbuf + sizeof(uoffset_t), newbuf + newlen); auto root_offset = ReadScalar(newbuf) - sizeof(uoffset_t); - return vector_data(flatbuf) + insertion_point + root_offset; + return flatbuf.data() + insertion_point + root_offset; } void CopyInline(FlatBufferBuilder &fbb, const reflection::Field &fielddef, diff --git a/src/util.cpp b/src/util.cpp index 1a2b5f091fc..0da2db6ceb2 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -158,7 +158,7 @@ std::string ConCatPathFileName(const std::string &path, const std::string &filename) { std::string filepath = path; if (filepath.length()) { - char &filepath_last_character = string_back(filepath); + char &filepath_last_character = filepath.back(); if (filepath_last_character == kPathSeparatorWindows) { filepath_last_character = kPathSeparator; } else if (filepath_last_character != kPathSeparator) { @@ -274,7 +274,7 @@ ClassicLocale ClassicLocale::instance_; std::string RemoveStringQuotes(const std::string &s) { auto ch = *s.c_str(); return ((s.size() >= 2) && (ch == '\"' || ch == '\'') && - (ch == string_back(s))) + (ch == s.back())) ? s.substr(1, s.length() - 2) : s; } diff --git a/tests/cpp17/generated_cpp17/monster_test_generated.h b/tests/cpp17/generated_cpp17/monster_test_generated.h index ee2e86cd4dd..430d7aaf7d8 100644 --- a/tests/cpp17/generated_cpp17/monster_test_generated.h +++ b/tests/cpp17/generated_cpp17/monster_test_generated.h @@ -229,7 +229,6 @@ struct AnyUnion { void Reset(); -#ifndef FLATBUFFERS_CPP98_STL template void Set(T&& val) { using RT = typename std::remove_reference::type; @@ -239,7 +238,6 @@ struct AnyUnion { value = new RT(std::forward(val)); } } -#endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, Any type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; @@ -342,7 +340,6 @@ struct AnyUniqueAliasesUnion { void Reset(); -#ifndef FLATBUFFERS_CPP98_STL template void Set(T&& val) { using RT = typename std::remove_reference::type; @@ -352,7 +349,6 @@ struct AnyUniqueAliasesUnion { value = new RT(std::forward(val)); } } -#endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, AnyUniqueAliases type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h index faa95d9d7e1..598dc9020fe 100644 --- a/tests/monster_test_generated.h +++ b/tests/monster_test_generated.h @@ -259,7 +259,6 @@ struct AnyUnion { void Reset(); -#ifndef FLATBUFFERS_CPP98_STL template void Set(T&& val) { using RT = typename std::remove_reference::type; @@ -269,7 +268,6 @@ struct AnyUnion { value = new RT(std::forward(val)); } } -#endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, Any type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; @@ -401,7 +399,6 @@ struct AnyUniqueAliasesUnion { void Reset(); -#ifndef FLATBUFFERS_CPP98_STL template void Set(T&& val) { using RT = typename std::remove_reference::type; @@ -411,7 +408,6 @@ struct AnyUniqueAliasesUnion { value = new RT(std::forward(val)); } } -#endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, AnyUniqueAliases type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; diff --git a/tests/namespace_test/namespace_test1_generated.h b/tests/namespace_test/namespace_test1_generated.h index b40e407090a..0fab792d6c8 100644 --- a/tests/namespace_test/namespace_test1_generated.h +++ b/tests/namespace_test/namespace_test1_generated.h @@ -79,7 +79,6 @@ struct UnionInNestedNSUnion { void Reset(); -#ifndef FLATBUFFERS_CPP98_STL template void Set(T&& val) { using RT = typename std::remove_reference::type; @@ -89,7 +88,6 @@ struct UnionInNestedNSUnion { value = new RT(std::forward(val)); } } -#endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, UnionInNestedNS type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; diff --git a/tests/test.cpp b/tests/test.cpp index 1c99b519b3d..e5ec7b12375 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -22,14 +22,6 @@ #include "flatbuffers/registry.h" #include "flatbuffers/util.h" -// clang-format off -#ifdef FLATBUFFERS_CPP98_STL - namespace std { - using flatbuffers::unique_ptr; - } -#endif -// clang-format on - #include "monster_test_generated.h" #include "namespace_test/namespace_test1_generated.h" #include "namespace_test/namespace_test2_generated.h" @@ -107,21 +99,11 @@ flatbuffers::DetachedBuffer CreateFlatBufferTest(std::string &buffer) { Test tests[] = { Test(10, 20), Test(30, 40) }; auto testv = builder.CreateVectorOfStructs(tests, 2); - // clang-format off - #ifndef FLATBUFFERS_CPP98_STL - // Create a vector of structures from a lambda. - auto testv2 = builder.CreateVectorOfStructs( - 2, [&](size_t i, Test* s) -> void { - *s = tests[i]; - }); - #else - // Create a vector of structures using a plain old C++ function. - auto testv2 = builder.CreateVectorOfStructs( - 2, [](size_t i, Test* s, void *state) -> void { - *s = (reinterpret_cast(state))[i]; - }, tests); - #endif // FLATBUFFERS_CPP98_STL - // clang-format on + // Create a vector of structures from a lambda. + auto testv2 = builder.CreateVectorOfStructs( + 2, [&](size_t i, Test* s) -> void { + *s = tests[i]; + }); // create monster with very few fields set: // (same functionality as CreateMonster below, but sets fields manually) @@ -1071,8 +1053,7 @@ void ReflectionTest(uint8_t *flatbuf, size_t length) { // Get the root. // This time we wrap the result from GetAnyRoot in a smartpointer that // will keep rroot valid as resizingbuf resizes. - auto rroot = flatbuffers::piv( - flatbuffers::GetAnyRoot(flatbuffers::vector_data(resizingbuf)), + auto rroot = flatbuffers::piv(flatbuffers::GetAnyRoot(resizingbuf.data()), resizingbuf); SetString(schema, "totally new string", GetFieldS(**rroot, name_field), &resizingbuf); @@ -1117,13 +1098,12 @@ void ReflectionTest(uint8_t *flatbuf, size_t length) { TEST_EQ_STR(rtestarrayofstring->Get(2)->c_str(), "hank"); // Test integrity of all resize operations above. flatbuffers::Verifier resize_verifier( - reinterpret_cast(flatbuffers::vector_data(resizingbuf)), + reinterpret_cast(resizingbuf.data()), resizingbuf.size()); TEST_EQ(VerifyMonsterBuffer(resize_verifier), true); // Test buffer is valid using reflection as well - TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), - flatbuffers::vector_data(resizingbuf), + TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), resizingbuf.data(), resizingbuf.size()), true); @@ -3000,60 +2980,36 @@ void FlexBuffersTest() { // Write the equivalent of: // { vec: [ -100, "Fred", 4.0, false ], bar: [ 1, 2, 3 ], bar3: [ 1, 2, 3 ], // foo: 100, bool: true, mymap: { foo: "Fred" } } - // clang-format off - #ifndef FLATBUFFERS_CPP98_STL - // It's possible to do this without std::function support as well. - slb.Map([&]() { - slb.Vector("vec", [&]() { - slb += -100; // Equivalent to slb.Add(-100) or slb.Int(-100); - slb += "Fred"; - slb.IndirectFloat(4.0f); - auto i_f = slb.LastValue(); - uint8_t blob[] = { 77 }; - slb.Blob(blob, 1); - slb += false; - slb.ReuseValue(i_f); - }); - int ints[] = { 1, 2, 3 }; - slb.Vector("bar", ints, 3); - slb.FixedTypedVector("bar3", ints, 3); - bool bools[] = {true, false, true, false}; - slb.Vector("bools", bools, 4); - slb.Bool("bool", true); - slb.Double("foo", 100); - slb.Map("mymap", [&]() { - slb.String("foo", "Fred"); // Testing key and string reuse. - }); + + // It's possible to do this without std::function support as well. + slb.Map([&]() { + slb.Vector("vec", [&]() { + slb += -100; // Equivalent to slb.Add(-100) or slb.Int(-100); + slb += "Fred"; + slb.IndirectFloat(4.0f); + auto i_f = slb.LastValue(); + uint8_t blob[] = { 77 }; + slb.Blob(blob, 1); + slb += false; + slb.ReuseValue(i_f); }); - slb.Finish(); - #else - // It's possible to do this without std::function support as well. - slb.Map([](flexbuffers::Builder& slb2) { - slb2.Vector("vec", [](flexbuffers::Builder& slb3) { - slb3 += -100; // Equivalent to slb.Add(-100) or slb.Int(-100); - slb3 += "Fred"; - slb3.IndirectFloat(4.0f); - auto i_f = slb3.LastValue(); - uint8_t blob[] = { 77 }; - slb3.Blob(blob, 1); - slb3 += false; - slb3.ReuseValue(i_f); - }, slb2); - int ints[] = { 1, 2, 3 }; - slb2.Vector("bar", ints, 3); - slb2.FixedTypedVector("bar3", ints, 3); - slb2.Bool("bool", true); - slb2.Double("foo", 100); - slb2.Map("mymap", [](flexbuffers::Builder& slb3) { - slb3.String("foo", "Fred"); // Testing key and string reuse. - }, slb2); - }, slb); - slb.Finish(); - #endif // FLATBUFFERS_CPP98_STL + int ints[] = { 1, 2, 3 }; + slb.Vector("bar", ints, 3); + slb.FixedTypedVector("bar3", ints, 3); + bool bools[] = {true, false, true, false}; + slb.Vector("bools", bools, 4); + slb.Bool("bool", true); + slb.Double("foo", 100); + slb.Map("mymap", [&]() { + slb.String("foo", "Fred"); // Testing key and string reuse. + }); + }); + slb.Finish(); + // clang-format off #ifdef FLATBUFFERS_TEST_VERBOSE for (size_t i = 0; i < slb.GetBuffer().size(); i++) - printf("%d ", flatbuffers::vector_data(slb.GetBuffer())[i]); + printf("%d ", slb.GetBuffer().data()[i]); printf("\n"); #endif // clang-format on @@ -4142,11 +4098,7 @@ int FlatBufferTests() { std::string rawbuf; auto flatbuf1 = CreateFlatBufferTest(rawbuf); - #if !defined(FLATBUFFERS_CPP98_STL) - auto flatbuf = std::move(flatbuf1); // Test move assignment. - #else - auto &flatbuf = flatbuf1; - #endif // !defined(FLATBUFFERS_CPP98_STL) + auto flatbuf = std::move(flatbuf1); // Test move assignment. TriviallyCopyableTest(); diff --git a/tests/test_assert.h b/tests/test_assert.h index 353e3cee389..e6140cc9a08 100644 --- a/tests/test_assert.h +++ b/tests/test_assert.h @@ -73,7 +73,7 @@ struct underlying_of_scalar { template struct underlying_of_scalar { // clang-format off // There are old compilers without full C++11 support (see stl_emulation.h). - #if defined(FLATBUFFERS_TEMPLATES_ALIASES) && !defined(FLATBUFFERS_CPP98_STL) + #if defined(FLATBUFFERS_TEMPLATES_ALIASES) using type = typename std::underlying_type::type; #else typedef int64_t type; diff --git a/tests/test_builder.cpp b/tests/test_builder.cpp index 3a12d79d2b7..ae67076a096 100644 --- a/tests/test_builder.cpp +++ b/tests/test_builder.cpp @@ -9,20 +9,13 @@ struct OwnedAllocator : public flatbuffers::DefaultAllocator {}; class TestHeapBuilder : public flatbuffers::FlatBufferBuilder { private: - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) TestHeapBuilder(const TestHeapBuilder &); TestHeapBuilder &operator=(const TestHeapBuilder &); - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on public: TestHeapBuilder() : flatbuffers::FlatBufferBuilder(2048, new OwnedAllocator(), true) {} - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on TestHeapBuilder(TestHeapBuilder &&other) : FlatBufferBuilder(std::move(other)) {} @@ -30,9 +23,6 @@ class TestHeapBuilder : public flatbuffers::FlatBufferBuilder { FlatBufferBuilder::operator=(std::move(other)); return *this; } - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on }; // This class simulates flatbuffers::grpc::detail::SliceAllocatorMember @@ -56,18 +46,12 @@ struct GrpcLikeMessageBuilder : private AllocatorMember, Swap(other); } - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on GrpcLikeMessageBuilder &operator=(GrpcLikeMessageBuilder &&other) { // Construct temporary and swap idiom GrpcLikeMessageBuilder temp(std::move(other)); Swap(temp); return *this; } - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on void Swap(GrpcLikeMessageBuilder &other) { // No need to swap member_allocator_ because it's stateless. @@ -155,4 +139,4 @@ void FlatBufferBuilderTest() { } // Link-time check using pointer type. -void CheckTestGeneratedIsValid(const MyGame::Example::Color &) {} \ No newline at end of file +void CheckTestGeneratedIsValid(const MyGame::Example::Color &) {} diff --git a/tests/test_builder.h b/tests/test_builder.h index 5555e907175..6d97ac009a7 100644 --- a/tests/test_builder.h +++ b/tests/test_builder.h @@ -54,9 +54,6 @@ bool release_n_verify(flatbuffers::FlatBufferBuilder &fbb, bool release_n_verify(flatbuffers::grpc::MessageBuilder &mbb, const std::string &expected_name, Color color); -// clang-format off -#if !defined(FLATBUFFERS_CPP98_STL) -// clang-format on // Invokes this function when testing the following Builder types // FlatBufferBuilder, TestHeapBuilder, and GrpcLikeMessageBuilder template @@ -78,18 +75,12 @@ void builder_move_assign_after_releaseraw_test(Builder b1) { TEST_ASSERT_FUNC(release_n_verify(b1, m2_name(), m2_color())); TEST_EQ_FUNC(src.GetSize(), 0); } -// clang-format off -#endif // !defined(FLATBUFFERS_CPP98_STL) -// clang-format on void builder_move_assign_after_releaseraw_test( flatbuffers::grpc::MessageBuilder b1); template struct BuilderTests { - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on static void empty_builder_movector_test() { SrcBuilder src; size_t src_size = src.GetSize(); @@ -171,9 +162,6 @@ struct BuilderTests { TEST_ASSERT_FUNC(release_n_verify(dst, m2_name(), m2_color())); TEST_EQ_FUNC(src.GetSize(), 0); } - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on static void builder_swap_before_finish_test( bool run = is_same::value) { @@ -216,9 +204,6 @@ struct BuilderTests { } static void all_tests() { - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on empty_builder_movector_test(); nonempty_builder_movector_test(); builder_movector_before_finish_test(); @@ -227,9 +212,6 @@ struct BuilderTests { builder_move_assign_after_finish_test(); builder_move_assign_after_release_test(); builder_move_assign_after_releaseraw_test(DestBuilder()); - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on builder_swap_before_finish_test(); builder_swap_after_finish_test(); } @@ -274,9 +256,6 @@ template struct BuilderReuseTests { } } - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on static void builder_reusable_after_release_and_move_assign_test( TestSelector selector) { if (!selector.count(REUSABLE_AFTER_RELEASE_AND_MOVE_ASSIGN)) { return; } @@ -311,21 +290,12 @@ template struct BuilderReuseTests { TEST_EQ_FUNC(src.GetSize(), 0); } } - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on static void run_tests(TestSelector selector) { builder_reusable_after_release_test(selector); builder_reusable_after_releaseraw_test(selector); - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on builder_reusable_after_release_and_move_assign_test(selector); builder_reusable_after_releaseraw_and_move_assign_test(selector); - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on } };