Minor fixes for FloatSpec, IntegerSpec and types.hpp

This commit is contained in:
Pavel Kirienko
2014-02-22 20:47:54 +04:00
parent fb32aabb54
commit 202fa3b58b
3 changed files with 10 additions and 8 deletions
@@ -31,7 +31,7 @@ class IEEE754Converter
static uint16_t nativeNonIeeeToHalf(float value);
static float halfToNativeNonIeee(uint16_t value);
IEEE754Converter() { }
IEEE754Converter();
public:
/// UAVCAN requires rounding to nearest for all float conversions
@@ -62,19 +62,18 @@ public:
}
};
template <>
typename IntegerSpec<16, SignednessUnsigned, CastModeTruncate>::StorageType
inline typename IntegerSpec<16, SignednessUnsigned, CastModeTruncate>::StorageType
IEEE754Converter::toIeee<16>(typename NativeFloatSelector<16>::Type value)
{
return nativeNonIeeeToHalf(value);
}
template <>
typename NativeFloatSelector<16>::Type
inline typename NativeFloatSelector<16>::Type
IEEE754Converter::toNative<16>(typename IntegerSpec<16, SignednessUnsigned, CastModeTruncate>::StorageType value)
{
return halfToNativeNonIeee(value);
}
template <unsigned int BitLen> struct IEEE754Limits;
template <> struct IEEE754Limits<16>
{
@@ -96,7 +95,7 @@ template <> struct IEEE754Limits<64>
template <unsigned int BitLen_, CastMode CastMode>
class FloatSpec : public IEEE754Limits<BitLen_>
{
FloatSpec() { }
FloatSpec();
public:
enum { BitLen = BitLen_ };
@@ -34,7 +34,7 @@ public:
private:
typedef typename IntegerSpec<BitLen, SignednessUnsigned, CastMode>::StorageType UnsignedStorageType;
IntegerSpec() { }
IntegerSpec();
struct ExactSizeLimits
{
@@ -6,12 +6,13 @@
#include <uavcan/internal/util.hpp>
#include <uavcan/internal/marshalling/integer_spec.hpp>
#include <uavcan/internal/marshalling/float_spec.hpp>
namespace uavcan
{
template <typename T, typename Enable = void>
struct StorageTypeImpl { typedef T StorageType; };
struct StorageTypeImpl { typedef T Type; };
template <typename T>
struct StorageTypeImpl<T, typename EnableIfType<typename T::StorageType>::Type>
@@ -20,8 +21,10 @@ struct StorageTypeImpl<T, typename EnableIfType<typename T::StorageType>::Type>
};
template <typename T>
struct StorageType : public T
class StorageType : public T
{
StorageType();
public:
typedef typename StorageTypeImpl<T>::Type Type;
};