mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-07 05:47:36 +00:00
Extend the test of MonsterExtra (#5428)
* Extend the test of MonsterExtra - Extend C++ test of MonsterExtra - Add conversion of fbs/json NaNs to unsigned quiet-NaN - Update documentation (cross-platform interoperability) * Fix declaration of infinity constants int the test
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
47c7aa0361
commit
e304f8c115
@@ -25,16 +25,21 @@
|
||||
|
||||
namespace flatbuffers {
|
||||
// Generic 'operator==' with conditional specialisations.
|
||||
// T e - new value of a scalar field.
|
||||
// T def - default of scalar (is known at compile-time).
|
||||
template<typename T> inline bool IsTheSameAs(T e, T def) { return e == def; }
|
||||
|
||||
#if defined(FLATBUFFERS_NAN_DEFAULTS) && \
|
||||
(!defined(_MSC_VER) || _MSC_VER >= 1800)
|
||||
defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
|
||||
// Like `operator==(e, def)` with weak NaN if T=(float|double).
|
||||
template<typename T> inline bool IsFloatTheSameAs(T e, T def) {
|
||||
return (e == def) || ((def != def) && (e != e));
|
||||
}
|
||||
template<> inline bool IsTheSameAs<float>(float e, float def) {
|
||||
return (e == def) || (std::isnan(def) && std::isnan(e));
|
||||
return IsFloatTheSameAs(e, def);
|
||||
}
|
||||
template<> inline bool IsTheSameAs<double>(double e, double def) {
|
||||
return (e == def) || (std::isnan(def) && std::isnan(e));
|
||||
return IsFloatTheSameAs(e, def);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user