Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-27 09:30:24

0001 #ifndef FLATBUFFERS_BASE_H_
0002 #define FLATBUFFERS_BASE_H_
0003 
0004 // clang-format off
0005 
0006 // If activate should be declared and included first.
0007 #if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING) && \
0008     defined(_MSC_VER) && defined(_DEBUG)
0009   // The _CRTDBG_MAP_ALLOC inside <crtdbg.h> will replace
0010   // calloc/free (etc) to its debug version using #define directives.
0011   #define _CRTDBG_MAP_ALLOC
0012   #include <stdlib.h>
0013   #include <crtdbg.h>
0014   // Replace operator new by trace-enabled version.
0015   #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
0016   #define new DEBUG_NEW
0017 #endif
0018 
0019 #if !defined(FLATBUFFERS_ASSERT)
0020 #include <assert.h>
0021 #define FLATBUFFERS_ASSERT assert
0022 #elif defined(FLATBUFFERS_ASSERT_INCLUDE)
0023 // Include file with forward declaration
0024 #include FLATBUFFERS_ASSERT_INCLUDE
0025 #endif
0026 
0027 #ifndef ARDUINO
0028 #include <cstdint>
0029 #endif
0030 
0031 #include <cstddef>
0032 #include <cstdlib>
0033 #include <cstring>
0034 
0035 #if defined(ARDUINO) && !defined(ARDUINOSTL_M_H) && defined(__AVR__)
0036   #include <utility.h>
0037 #else
0038   #include <utility>
0039 #endif
0040 
0041 #include <string>
0042 #include <type_traits>
0043 #include <vector>
0044 #include <set>
0045 #include <algorithm>
0046 #include <limits>
0047 #include <iterator>
0048 #include <memory>
0049 
0050 #if defined(__unix__) && !defined(FLATBUFFERS_LOCALE_INDEPENDENT)
0051   #include <unistd.h>
0052 #endif
0053 
0054 #ifdef __ANDROID__
0055   #include <android/api-level.h>
0056 #endif
0057 
0058 #if defined(__ICCARM__)
0059 #include <intrinsics.h>
0060 #endif
0061 
0062 // Note the __clang__ check is needed, because clang presents itself
0063 // as an older GNUC compiler (4.2).
0064 // Clang 3.3 and later implement all of the ISO C++ 2011 standard.
0065 // Clang 3.4 and later implement all of the ISO C++ 2014 standard.
0066 // http://clang.llvm.org/cxx_status.html
0067 
0068 // Note the MSVC value '__cplusplus' may be incorrect:
0069 // The '__cplusplus' predefined macro in the MSVC stuck at the value 199711L,
0070 // indicating (erroneously!) that the compiler conformed to the C++98 Standard.
0071 // This value should be correct starting from MSVC2017-15.7-Preview-3.
0072 // The '__cplusplus' will be valid only if MSVC2017-15.7-P3 and the `/Zc:__cplusplus` switch is set.
0073 // Workaround (for details see MSDN):
0074 // Use the _MSC_VER and _MSVC_LANG definition instead of the __cplusplus  for compatibility.
0075 // The _MSVC_LANG macro reports the Standard version regardless of the '/Zc:__cplusplus' switch.
0076 
0077 #if defined(__GNUC__) && !defined(__clang__)
0078   #define FLATBUFFERS_GCC (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
0079 #else
0080   #define FLATBUFFERS_GCC 0
0081 #endif
0082 
0083 #if defined(__clang__)
0084   #define FLATBUFFERS_CLANG (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
0085 #else
0086   #define FLATBUFFERS_CLANG 0
0087 #endif
0088 
0089 /// @cond FLATBUFFERS_INTERNAL
0090 #if __cplusplus <= 199711L && \
0091     (!defined(_MSC_VER) || _MSC_VER < 1600) && \
0092     (!defined(__GNUC__) || \
0093       (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40400))
0094   #error A C++11 compatible compiler with support for the auto typing is \
0095          required for FlatBuffers.
0096   #error __cplusplus _MSC_VER __GNUC__  __GNUC_MINOR__  __GNUC_PATCHLEVEL__
0097 #endif
0098 
0099 #if !defined(__clang__) && \
0100     defined(__GNUC__) && \
0101     (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40600)
0102   // Backwards compatibility for g++ 4.4, and 4.5 which don't have the nullptr
0103   // and constexpr keywords. Note the __clang__ check is needed, because clang
0104   // presents itself as an older GNUC compiler.
0105   #ifndef nullptr_t
0106     const class nullptr_t {
0107     public:
0108       template<class T> inline operator T*() const { return 0; }
0109     private:
0110       void operator&() const;
0111     } nullptr = {};
0112   #endif
0113   #ifndef constexpr
0114     #define constexpr const
0115   #endif
0116 #endif
0117 
0118 // The wire format uses a little endian encoding (since that's efficient for
0119 // the common platforms).
0120 #if defined(__s390x__)
0121   #define FLATBUFFERS_LITTLEENDIAN 0
0122 #endif // __s390x__
0123 #if !defined(FLATBUFFERS_LITTLEENDIAN)
0124   #if defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__)
0125     #if (defined(__BIG_ENDIAN__) || \
0126          (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
0127       #define FLATBUFFERS_LITTLEENDIAN 0
0128     #else
0129       #define FLATBUFFERS_LITTLEENDIAN 1
0130     #endif // __BIG_ENDIAN__
0131   #elif defined(_MSC_VER)
0132     #if defined(_M_PPC)
0133       #define FLATBUFFERS_LITTLEENDIAN 0
0134     #else
0135       #define FLATBUFFERS_LITTLEENDIAN 1
0136     #endif
0137   #else
0138     #error Unable to determine endianness, define FLATBUFFERS_LITTLEENDIAN.
0139   #endif
0140 #endif // !defined(FLATBUFFERS_LITTLEENDIAN)
0141 
0142 #define FLATBUFFERS_VERSION_MAJOR 24
0143 #define FLATBUFFERS_VERSION_MINOR 12
0144 #define FLATBUFFERS_VERSION_REVISION 23
0145 #define FLATBUFFERS_STRING_EXPAND(X) #X
0146 #define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
0147 namespace flatbuffers {
0148   // Returns version as string  "MAJOR.MINOR.REVISION".
0149   const char* FLATBUFFERS_VERSION();
0150 }
0151 
0152 #if (!defined(_MSC_VER) || _MSC_VER > 1600) && \
0153     (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 407)) || \
0154     defined(__clang__)
0155   #define FLATBUFFERS_FINAL_CLASS final
0156   #define FLATBUFFERS_OVERRIDE override
0157   #define FLATBUFFERS_EXPLICIT_CPP11 explicit
0158   #define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : ::flatbuffers::voffset_t
0159 #else
0160   #define FLATBUFFERS_FINAL_CLASS
0161   #define FLATBUFFERS_OVERRIDE
0162   #define FLATBUFFERS_EXPLICIT_CPP11
0163   #define FLATBUFFERS_VTABLE_UNDERLYING_TYPE
0164 #endif
0165 
0166 #if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \
0167     (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \
0168     (defined(__cpp_constexpr) && __cpp_constexpr >= 200704)
0169   #define FLATBUFFERS_CONSTEXPR constexpr
0170   #define FLATBUFFERS_CONSTEXPR_CPP11 constexpr
0171   #define FLATBUFFERS_CONSTEXPR_DEFINED
0172 #else
0173   #define FLATBUFFERS_CONSTEXPR const
0174   #define FLATBUFFERS_CONSTEXPR_CPP11
0175 #endif
0176 
0177 #if (defined(__cplusplus) && __cplusplus >= 201402L) || \
0178     (defined(__cpp_constexpr) && __cpp_constexpr >= 201304)
0179   #define FLATBUFFERS_CONSTEXPR_CPP14 FLATBUFFERS_CONSTEXPR_CPP11
0180 #else
0181   #define FLATBUFFERS_CONSTEXPR_CPP14
0182 #endif
0183 
0184 #if (defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \
0185     (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023026)) || \
0186     defined(__clang__)
0187   #define FLATBUFFERS_NOEXCEPT noexcept
0188 #else
0189   #define FLATBUFFERS_NOEXCEPT
0190 #endif
0191 
0192 // NOTE: the FLATBUFFERS_DELETE_FUNC macro may change the access mode to
0193 // private, so be sure to put it at the end or reset access mode explicitly.
0194 #if (!defined(_MSC_VER) || _MSC_FULL_VER >= 180020827) && \
0195     (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 404)) || \
0196     defined(__clang__)
0197   #define FLATBUFFERS_DELETE_FUNC(func) func = delete
0198 #else
0199   #define FLATBUFFERS_DELETE_FUNC(func) private: func
0200 #endif
0201 
0202 #if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \
0203     (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)) || \
0204     defined(__clang__)
0205   #define FLATBUFFERS_DEFAULT_DECLARATION
0206 #endif
0207 
0208 // Check if we can use template aliases
0209 // Not possible if Microsoft Compiler before 2012
0210 // Possible is the language feature __cpp_alias_templates is defined well
0211 // Or possible if the C++ std is C+11 or newer
0212 #if (defined(_MSC_VER) && _MSC_VER > 1700 /* MSVC2012 */) \
0213     || (defined(__cpp_alias_templates) && __cpp_alias_templates >= 200704) \
0214     || (defined(__cplusplus) && __cplusplus >= 201103L)
0215   #define FLATBUFFERS_TEMPLATES_ALIASES
0216 #endif
0217 
0218 #ifndef FLATBUFFERS_HAS_STRING_VIEW
0219   // Only provide flatbuffers::string_view if __has_include can be used
0220   // to detect a header that provides an implementation
0221   #if defined(__has_include)
0222     // Check for std::string_view (in c++17)
0223     #if __has_include(<string_view>) && (__cplusplus >= 201606 || (defined(_HAS_CXX17) && _HAS_CXX17))
0224       #include <string_view>
0225       namespace flatbuffers {
0226         typedef std::string_view string_view;
0227       }
0228       #define FLATBUFFERS_HAS_STRING_VIEW 1
0229     // Check for std::experimental::string_view (in c++14, compiler-dependent)
0230     #elif __has_include(<experimental/string_view>) && (__cplusplus >= 201411)
0231       #include <experimental/string_view>
0232       namespace flatbuffers {
0233         typedef std::experimental::string_view string_view;
0234       }
0235       #define FLATBUFFERS_HAS_STRING_VIEW 1
0236     // Check for absl::string_view
0237     #elif __has_include("absl/strings/string_view.h") && \
0238           __has_include("absl/base/config.h") && \
0239           (__cplusplus >= 201411)
0240       #include "absl/base/config.h"
0241       #if !defined(ABSL_USES_STD_STRING_VIEW)
0242         #include "absl/strings/string_view.h"
0243         namespace flatbuffers {
0244           typedef absl::string_view string_view;
0245         }
0246         #define FLATBUFFERS_HAS_STRING_VIEW 1
0247       #endif
0248     #endif
0249   #endif // __has_include
0250 #endif // !FLATBUFFERS_HAS_STRING_VIEW
0251 
0252 #ifndef FLATBUFFERS_GENERAL_HEAP_ALLOC_OK
0253   // Allow heap allocations to be used
0254   #define FLATBUFFERS_GENERAL_HEAP_ALLOC_OK 1
0255 #endif // !FLATBUFFERS_GENERAL_HEAP_ALLOC_OK
0256 
0257 #ifndef FLATBUFFERS_HAS_NEW_STRTOD
0258   // Modern (C++11) strtod and strtof functions are available for use.
0259   // 1) nan/inf strings as argument of strtod;
0260   // 2) hex-float  as argument of  strtod/strtof.
0261   #if (defined(_MSC_VER) && _MSC_VER >= 1900) || \
0262       (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)) || \
0263       (defined(__clang__))
0264     #define FLATBUFFERS_HAS_NEW_STRTOD 1
0265   #endif
0266 #endif // !FLATBUFFERS_HAS_NEW_STRTOD
0267 
0268 #ifndef FLATBUFFERS_LOCALE_INDEPENDENT
0269   // Enable locale independent functions {strtof_l, strtod_l,strtoll_l,
0270   // strtoull_l}.
0271   #if (defined(_MSC_VER) && _MSC_VER >= 1800) || \
0272       (defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \
0273       (defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \
0274         (!defined(__Fuchsia__) && !defined(__ANDROID_API__))
0275     #define FLATBUFFERS_LOCALE_INDEPENDENT 1
0276   #else
0277     #define FLATBUFFERS_LOCALE_INDEPENDENT 0
0278   #endif
0279 #endif  // !FLATBUFFERS_LOCALE_INDEPENDENT
0280 
0281 // Suppress Undefined Behavior Sanitizer (recoverable only). Usage:
0282 // - FLATBUFFERS_SUPPRESS_UBSAN("undefined")
0283 // - FLATBUFFERS_SUPPRESS_UBSAN("signed-integer-overflow")
0284 #if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))
0285   #define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize(type)))
0286 #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)
0287   #define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize_undefined))
0288 #else
0289   #define FLATBUFFERS_SUPPRESS_UBSAN(type)
0290 #endif
0291 
0292 namespace flatbuffers {
0293   // This is constexpr function used for checking compile-time constants.
0294   // Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
0295   template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
0296     return !!t;
0297   }
0298 }
0299 
0300 // Enable C++ attribute [[]] if std:c++17 or higher.
0301 #if ((__cplusplus >= 201703L) \
0302     || (defined(_MSVC_LANG) &&  (_MSVC_LANG >= 201703L)))
0303   // All attributes unknown to an implementation are ignored without causing an error.
0304   #define FLATBUFFERS_ATTRIBUTE(attr) attr
0305 
0306   #define FLATBUFFERS_FALLTHROUGH() [[fallthrough]]
0307 #else
0308   #define FLATBUFFERS_ATTRIBUTE(attr)
0309 
0310   #if FLATBUFFERS_CLANG >= 30800
0311     #define FLATBUFFERS_FALLTHROUGH() [[clang::fallthrough]]
0312   #elif FLATBUFFERS_GCC >= 70300
0313     #define FLATBUFFERS_FALLTHROUGH() [[gnu::fallthrough]]
0314   #else
0315     #define FLATBUFFERS_FALLTHROUGH()
0316   #endif
0317 #endif
0318 
0319 /// @endcond
0320 
0321 /// @file
0322 namespace flatbuffers {
0323 
0324 /// @cond FLATBUFFERS_INTERNAL
0325 // Our default offset / size type, 32bit on purpose on 64bit systems.
0326 // Also, using a consistent offset type maintains compatibility of serialized
0327 // offset values between 32bit and 64bit systems.
0328 typedef uint32_t uoffset_t;
0329 typedef uint64_t uoffset64_t;
0330 
0331 // Signed offsets for references that can go in both directions.
0332 typedef int32_t soffset_t;
0333 typedef int64_t soffset64_t;
0334 
0335 // Offset/index used in v-tables, can be changed to uint8_t in
0336 // format forks to save a bit of space if desired.
0337 typedef uint16_t voffset_t;
0338 
0339 typedef uintmax_t largest_scalar_t;
0340 
0341 // In 32bits, this evaluates to 2GB - 1
0342 #define FLATBUFFERS_MAX_BUFFER_SIZE (std::numeric_limits<::flatbuffers::soffset_t>::max)()
0343 #define FLATBUFFERS_MAX_64_BUFFER_SIZE (std::numeric_limits<::flatbuffers::soffset64_t>::max)()
0344 
0345 // The minimum size buffer that can be a valid flatbuffer.
0346 // Includes the offset to the root table (uoffset_t), the offset to the vtable
0347 // of the root table (soffset_t), the size of the vtable (uint16_t), and the
0348 // size of the referring table (uint16_t).
0349 #define FLATBUFFERS_MIN_BUFFER_SIZE sizeof(::flatbuffers::uoffset_t) + \
0350   sizeof(::flatbuffers::soffset_t) + sizeof(uint16_t) + sizeof(uint16_t)
0351 
0352 // We support aligning the contents of buffers up to this size.
0353 #ifndef FLATBUFFERS_MAX_ALIGNMENT
0354   #define FLATBUFFERS_MAX_ALIGNMENT 32
0355 #endif
0356 
0357 /// @brief The length of a FlatBuffer file header.
0358 static const size_t kFileIdentifierLength = 4;
0359 
0360 inline bool VerifyAlignmentRequirements(size_t align, size_t min_align = 1) {
0361   return (min_align <= align) && (align <= (FLATBUFFERS_MAX_ALIGNMENT)) &&
0362          (align & (align - 1)) == 0;  // must be power of 2
0363 }
0364 
0365 #if defined(_MSC_VER)
0366   #pragma warning(push)
0367   #pragma warning(disable: 4127) // C4127: conditional expression is constant
0368 #endif
0369 
0370 template<typename T> T EndianSwap(T t) {
0371   #if defined(_MSC_VER)
0372     #define FLATBUFFERS_BYTESWAP16 _byteswap_ushort
0373     #define FLATBUFFERS_BYTESWAP32 _byteswap_ulong
0374     #define FLATBUFFERS_BYTESWAP64 _byteswap_uint64
0375   #elif defined(__ICCARM__)
0376     #define FLATBUFFERS_BYTESWAP16 __REV16
0377     #define FLATBUFFERS_BYTESWAP32 __REV
0378     #define FLATBUFFERS_BYTESWAP64(x) \
0379        ((__REV(static_cast<uint32_t>(x >> 32U))) | (static_cast<uint64_t>(__REV(static_cast<uint32_t>(x)))) << 32U)
0380   #else
0381     #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408 && !defined(__clang__)
0382       // __builtin_bswap16 was missing prior to GCC 4.8.
0383       #define FLATBUFFERS_BYTESWAP16(x) \
0384         static_cast<uint16_t>(__builtin_bswap32(static_cast<uint32_t>(x) << 16))
0385     #else
0386       #define FLATBUFFERS_BYTESWAP16 __builtin_bswap16
0387     #endif
0388     #define FLATBUFFERS_BYTESWAP32 __builtin_bswap32
0389     #define FLATBUFFERS_BYTESWAP64 __builtin_bswap64
0390   #endif
0391   if (sizeof(T) == 1) {   // Compile-time if-then's.
0392     return t;
0393   } else if (sizeof(T) == 2) {
0394     union { T t; uint16_t i; } u = { t };
0395     u.i = FLATBUFFERS_BYTESWAP16(u.i);
0396     return u.t;
0397   } else if (sizeof(T) == 4) {
0398     union { T t; uint32_t i; } u = { t };
0399     u.i = FLATBUFFERS_BYTESWAP32(u.i);
0400     return u.t;
0401   } else if (sizeof(T) == 8) {
0402     union { T t; uint64_t i; } u = { t };
0403     u.i = FLATBUFFERS_BYTESWAP64(u.i);
0404     return u.t;
0405   } else {
0406     FLATBUFFERS_ASSERT(0);
0407     return t;
0408   }
0409 }
0410 
0411 #if defined(_MSC_VER)
0412   #pragma warning(pop)
0413 #endif
0414 
0415 
0416 template<typename T> T EndianScalar(T t) {
0417   #if FLATBUFFERS_LITTLEENDIAN
0418     return t;
0419   #else
0420     return EndianSwap(t);
0421   #endif
0422 }
0423 
0424 template<typename T>
0425 // UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
0426 FLATBUFFERS_SUPPRESS_UBSAN("alignment")
0427 T ReadScalar(const void *p) {
0428   return EndianScalar(*reinterpret_cast<const T *>(p));
0429 }
0430 
0431 // See https://github.com/google/flatbuffers/issues/5950
0432 
0433 #if (FLATBUFFERS_GCC >= 100000) && (FLATBUFFERS_GCC < 110000)
0434   #pragma GCC diagnostic push
0435   #pragma GCC diagnostic ignored "-Wstringop-overflow"
0436 #endif
0437 
0438 template<typename T>
0439 // UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
0440 FLATBUFFERS_SUPPRESS_UBSAN("alignment")
0441 void WriteScalar(void *p, T t) {
0442   *reinterpret_cast<T *>(p) = EndianScalar(t);
0443 }
0444 
0445 template<typename T> struct Offset;
0446 template<typename T> FLATBUFFERS_SUPPRESS_UBSAN("alignment") void WriteScalar(void *p, Offset<T> t) {
0447   *reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
0448 }
0449 
0450 #if (FLATBUFFERS_GCC >= 100000) && (FLATBUFFERS_GCC < 110000)
0451   #pragma GCC diagnostic pop
0452 #endif
0453 
0454 // Computes how many bytes you'd have to pad to be able to write an
0455 // "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
0456 // memory).
0457 FLATBUFFERS_SUPPRESS_UBSAN("unsigned-integer-overflow")
0458 inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) {
0459   return ((~buf_size) + 1) & (scalar_size - 1);
0460 }
0461 
0462 #if !defined(_MSC_VER)
0463   #pragma GCC diagnostic push
0464   #pragma GCC diagnostic ignored "-Wfloat-equal"
0465 #endif
0466 // Generic 'operator==' with conditional specialisations.
0467 // T e - new value of a scalar field.
0468 // T def - default of scalar (is known at compile-time).
0469 template<typename T> inline bool IsTheSameAs(T e, T def) { return e == def; }
0470 #if !defined(_MSC_VER)
0471   #pragma GCC diagnostic pop
0472 #endif
0473 
0474 #if defined(FLATBUFFERS_NAN_DEFAULTS) && \
0475     defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
0476 // Like `operator==(e, def)` with weak NaN if T=(float|double).
0477 template<typename T> inline bool IsFloatTheSameAs(T e, T def) {
0478   return (e == def) || ((def != def) && (e != e));
0479 }
0480 template<> inline bool IsTheSameAs<float>(float e, float def) {
0481   return IsFloatTheSameAs(e, def);
0482 }
0483 template<> inline bool IsTheSameAs<double>(double e, double def) {
0484   return IsFloatTheSameAs(e, def);
0485 }
0486 #endif
0487 
0488 // Check 'v' is out of closed range [low; high].
0489 // Workaround for GCC warning [-Werror=type-limits]:
0490 // comparison is always true due to limited range of data type.
0491 template<typename T>
0492 inline bool IsOutRange(const T &v, const T &low, const T &high) {
0493   return (v < low) || (high < v);
0494 }
0495 
0496 // Check 'v' is in closed range [low; high].
0497 template<typename T>
0498 inline bool IsInRange(const T &v, const T &low, const T &high) {
0499   return !IsOutRange(v, low, high);
0500 }
0501 
0502 }  // namespace flatbuffers
0503 #endif  // FLATBUFFERS_BASE_H_