mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 02:53:34 +08:00
First stab at fixing #55
This commit is contained in:
@@ -1085,16 +1085,23 @@ public:
|
|||||||
typedef SizeType size_type;
|
typedef SizeType size_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These operators will only be enabled if rhs and lhs are different types. This precondition allows to work-around
|
||||||
|
* the ambiguity arising from the scope containing two definitions: one here and the others in Array<>.
|
||||||
|
* Refer to https://github.com/UAVCAN/libuavcan/issues/55 for more info.
|
||||||
|
*/
|
||||||
template <typename R, typename T, ArrayMode ArrayMode, unsigned MaxSize>
|
template <typename R, typename T, ArrayMode ArrayMode, unsigned MaxSize>
|
||||||
UAVCAN_EXPORT
|
UAVCAN_EXPORT
|
||||||
inline bool operator==(const R& rhs, const Array<T, ArrayMode, MaxSize>& lhs)
|
inline typename EnableIf<!IsSameType<R, Array<T, ArrayMode, MaxSize> >::Result, bool>::Type
|
||||||
|
operator==(const R& rhs, const Array<T, ArrayMode, MaxSize>& lhs)
|
||||||
{
|
{
|
||||||
return lhs.operator==(rhs);
|
return lhs.operator==(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R, typename T, ArrayMode ArrayMode, unsigned MaxSize>
|
template <typename R, typename T, ArrayMode ArrayMode, unsigned MaxSize>
|
||||||
UAVCAN_EXPORT
|
UAVCAN_EXPORT
|
||||||
inline bool operator!=(const R& rhs, const Array<T, ArrayMode, MaxSize>& lhs)
|
inline typename EnableIf<!IsSameType<R, Array<T, ArrayMode, MaxSize> >::Result, bool>::Type
|
||||||
|
operator!=(const R& rhs, const Array<T, ArrayMode, MaxSize>& lhs)
|
||||||
{
|
{
|
||||||
return lhs.operator!=(rhs);
|
return lhs.operator!=(rhs);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,21 @@ struct UAVCAN_EXPORT Select<false, TrueType, FalseType>
|
|||||||
typedef FalseType Result;
|
typedef FalseType Result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if two identifiers refer to the same type.
|
||||||
|
*/
|
||||||
|
template<class T, class U>
|
||||||
|
struct IsSameType
|
||||||
|
{
|
||||||
|
enum { Result = 0 };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct IsSameType<T, T>
|
||||||
|
{
|
||||||
|
enum { Result = 1 };
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove reference as in <type_traits>
|
* Remove reference as in <type_traits>
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user