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