From aeb8beadc13ae32da55e65d9e3b7c5564152e856 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 21 Aug 2015 15:00:50 +0300 Subject: [PATCH] IEEE754Converter::enforceIeee<>() --- libuavcan/include/uavcan/marshal/float_spec.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libuavcan/include/uavcan/marshal/float_spec.hpp b/libuavcan/include/uavcan/marshal/float_spec.hpp index 1e8627c052..aa2604c9d5 100644 --- a/libuavcan/include/uavcan/marshal/float_spec.hpp +++ b/libuavcan/include/uavcan/marshal/float_spec.hpp @@ -43,6 +43,16 @@ class UAVCAN_EXPORT IEEE754Converter IEEE754Converter(); + template + static void enforceIeee() + { + /* + * Some compilers may have is_iec559 to be defined false despite the fact that IEEE754 is supported. + * An acceptable workaround would be to put an #ifdef here. + */ + StaticAssert::Type>::is_iec559>::check(); + } + public: #if UAVCAN_CPP_VERSION >= UAVCAN_CPP11 /// UAVCAN requires rounding to nearest for all float conversions @@ -53,6 +63,7 @@ public: static typename IntegerSpec::StorageType toIeee(typename NativeFloatSelector::Type value) { + enforceIeee(); union { typename IntegerSpec::StorageType i; @@ -67,6 +78,7 @@ public: static typename NativeFloatSelector::Type toNative(typename IntegerSpec::StorageType value) { + enforceIeee(); union { typename IntegerSpec::StorageType i;