First stab at fixing #55

This commit is contained in:
Pavel Kirienko
2015-08-15 13:15:44 +03:00
parent f3931f7fc5
commit e32dfafbae
2 changed files with 24 additions and 2 deletions
+9 -2
View File
@@ -1085,16 +1085,23 @@ public:
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>
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);
}
template <typename R, typename T, ArrayMode ArrayMode, unsigned MaxSize>
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);
}