mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 21:43:33 +08:00
StaticIf<> renamed to much more appropriate and widely known name - Select<>
This commit is contained in:
@@ -104,14 +104,12 @@ public:
|
|||||||
* Statically allocated array with optional dynamic-like behavior
|
* Statically allocated array with optional dynamic-like behavior
|
||||||
*/
|
*/
|
||||||
template <typename T, ArrayMode ArrayMode, unsigned int MaxSize>
|
template <typename T, ArrayMode ArrayMode, unsigned int MaxSize>
|
||||||
class ArrayImpl : public StaticIf<ArrayMode == ArrayModeDynamic,
|
class ArrayImpl : public Select<ArrayMode == ArrayModeDynamic,
|
||||||
DynamicArrayBase<MaxSize>,
|
DynamicArrayBase<MaxSize>, StaticArrayBase<MaxSize> >::Result
|
||||||
StaticArrayBase<MaxSize> >::Result
|
|
||||||
{
|
{
|
||||||
typedef ArrayImpl<T, ArrayMode, MaxSize> SelfType;
|
typedef ArrayImpl<T, ArrayMode, MaxSize> SelfType;
|
||||||
typedef typename StaticIf<ArrayMode == ArrayModeDynamic,
|
typedef typename Select<ArrayMode == ArrayModeDynamic,
|
||||||
DynamicArrayBase<MaxSize>,
|
DynamicArrayBase<MaxSize>, StaticArrayBase<MaxSize> >::Result Base;
|
||||||
StaticArrayBase<MaxSize> >::Result Base;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
@@ -181,11 +179,10 @@ public:
|
|||||||
template <unsigned int MaxSize, ArrayMode ArrayMode, CastMode CastMode>
|
template <unsigned int MaxSize, ArrayMode ArrayMode, CastMode CastMode>
|
||||||
class ArrayImpl<IntegerSpec<1, SignednessUnsigned, CastMode>, ArrayMode, MaxSize>
|
class ArrayImpl<IntegerSpec<1, SignednessUnsigned, CastMode>, ArrayMode, MaxSize>
|
||||||
: public std::bitset<MaxSize>
|
: public std::bitset<MaxSize>
|
||||||
, public StaticIf<ArrayMode == ArrayModeDynamic, DynamicArrayBase<MaxSize>, StaticArrayBase<MaxSize> >::Result
|
, public Select<ArrayMode == ArrayModeDynamic, DynamicArrayBase<MaxSize>, StaticArrayBase<MaxSize> >::Result
|
||||||
{
|
{
|
||||||
typedef typename StaticIf<ArrayMode == ArrayModeDynamic,
|
typedef typename Select<ArrayMode == ArrayModeDynamic,
|
||||||
DynamicArrayBase<MaxSize>,
|
DynamicArrayBase<MaxSize>, StaticArrayBase<MaxSize> >::Result ArrayBase;
|
||||||
StaticArrayBase<MaxSize> >::Result ArrayBase;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { IsStringLike = 0 };
|
enum { IsStringLike = 0 };
|
||||||
@@ -527,8 +524,8 @@ public:
|
|||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
static void stream(Stream& s, const ArrayType& array, int level)
|
static void stream(Stream& s, const ArrayType& array, int level)
|
||||||
{
|
{
|
||||||
typedef typename StaticIf<ArrayType::IsStringLike, SelectorStringLike,
|
typedef typename Select<ArrayType::IsStringLike, SelectorStringLike,
|
||||||
typename StaticIf<IsPrimitiveType<typename ArrayType::RawValueType>::Result, SelectorPrimitives,
|
typename Select<IsPrimitiveType<typename ArrayType::RawValueType>::Result, SelectorPrimitives,
|
||||||
SelectorObjects>::Result >::Result Type;
|
SelectorObjects>::Result >::Result Type;
|
||||||
genericStreamImpl(s, array, level, Type());
|
genericStreamImpl(s, array, level, Type());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ template <unsigned int BitLen>
|
|||||||
struct NativeFloatSelector
|
struct NativeFloatSelector
|
||||||
{
|
{
|
||||||
struct ErrorNoSuchFloat;
|
struct ErrorNoSuchFloat;
|
||||||
typedef typename StaticIf<(sizeof(float) * 8 >= BitLen), float,
|
typedef typename Select<(sizeof(float) * 8 >= BitLen), float,
|
||||||
typename StaticIf<(sizeof(double) * 8 >= BitLen), double,
|
typename Select<(sizeof(double) * 8 >= BitLen), double,
|
||||||
typename StaticIf<(sizeof(long double) * 8 >= BitLen), long double,
|
typename Select<(sizeof(long double) * 8 >= BitLen), long double,
|
||||||
ErrorNoSuchFloat>::Result>::Result>::Result Type;
|
ErrorNoSuchFloat>::Result>::Result>::Result Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ public:
|
|||||||
enum { MaxBitLen = BitLen };
|
enum { MaxBitLen = BitLen };
|
||||||
enum { IsPrimitive = 1 };
|
enum { IsPrimitive = 1 };
|
||||||
|
|
||||||
typedef typename StaticIf<(BitLen <= 8), typename StaticIf<IsSigned, int8_t, uint8_t>::Result,
|
typedef typename Select<(BitLen <= 8), typename Select<IsSigned, int8_t, uint8_t>::Result,
|
||||||
typename StaticIf<(BitLen <= 16), typename StaticIf<IsSigned, int16_t, uint16_t>::Result,
|
typename Select<(BitLen <= 16), typename Select<IsSigned, int16_t, uint16_t>::Result,
|
||||||
typename StaticIf<(BitLen <= 32), typename StaticIf<IsSigned, int32_t, uint32_t>::Result,
|
typename Select<(BitLen <= 32), typename Select<IsSigned, int32_t, uint32_t>::Result,
|
||||||
typename StaticIf<(BitLen <= 64), typename StaticIf<IsSigned, int64_t, uint64_t>::Result,
|
typename Select<(BitLen <= 64), typename Select<IsSigned, int64_t, uint64_t>::Result,
|
||||||
ErrorNoSuchInteger>::Result>::Result>::Result>::Result StorageType;
|
ErrorNoSuchInteger>::Result>::Result>::Result>::Result StorageType;
|
||||||
|
|
||||||
typedef typename IntegerSpec<BitLen, SignednessUnsigned, CastMode>::StorageType UnsignedStorageType;
|
typedef typename IntegerSpec<BitLen, SignednessUnsigned, CastMode>::StorageType UnsignedStorageType;
|
||||||
@@ -59,7 +59,7 @@ private:
|
|||||||
static UnsignedStorageType mask() { return 0xFFFFFFFFFFFFFFFF; }
|
static UnsignedStorageType mask() { return 0xFFFFFFFFFFFFFFFF; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef typename StaticIf<(BitLen == 64), LimitsImpl64, LimitsImplGeneric>::Result Limits;
|
typedef typename Select<(BitLen == 64), LimitsImpl64, LimitsImplGeneric>::Result Limits;
|
||||||
|
|
||||||
static void saturate(StorageType& value)
|
static void saturate(StorageType& value)
|
||||||
{
|
{
|
||||||
@@ -127,8 +127,8 @@ struct YamlStreamer<IntegerSpec<BitLen, Signedness, CastMode> >
|
|||||||
static void stream(Stream& s, const StorageType value, int)
|
static void stream(Stream& s, const StorageType value, int)
|
||||||
{
|
{
|
||||||
// Get rid of character types - we want its integer representation, not ASCII code
|
// Get rid of character types - we want its integer representation, not ASCII code
|
||||||
typedef typename StaticIf<(sizeof(StorageType) >= sizeof(int)), StorageType,
|
typedef typename Select<(sizeof(StorageType) >= sizeof(int)), StorageType,
|
||||||
typename StaticIf<RawType::IsSigned, int, unsigned int>::Result >::Result TempType;
|
typename Select<RawType::IsSigned, int, unsigned int>::Result >::Result TempType;
|
||||||
s << TempType(value);
|
s << TempType(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -53,16 +53,16 @@ struct EnableIfType { typedef R Type; };
|
|||||||
|
|
||||||
|
|
||||||
template <bool Condition, typename TrueType, typename FalseType>
|
template <bool Condition, typename TrueType, typename FalseType>
|
||||||
struct StaticIf;
|
struct Select;
|
||||||
|
|
||||||
template <typename TrueType, typename FalseType>
|
template <typename TrueType, typename FalseType>
|
||||||
struct StaticIf<true, TrueType, FalseType>
|
struct Select<true, TrueType, FalseType>
|
||||||
{
|
{
|
||||||
typedef TrueType Result;
|
typedef TrueType Result;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename TrueType, typename FalseType>
|
template <typename TrueType, typename FalseType>
|
||||||
struct StaticIf<false, TrueType, FalseType>
|
struct Select<false, TrueType, FalseType>
|
||||||
{
|
{
|
||||||
typedef FalseType Result;
|
typedef FalseType Result;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user