areClose(), isClose()

This commit is contained in:
Pavel Kirienko
2014-08-28 20:25:27 +04:00
parent f255a725c1
commit 9d806c2be6
5 changed files with 148 additions and 9 deletions
+26 -1
View File
@@ -577,11 +577,36 @@ public:
/**
* This operator accepts any container with size() and [].
* Members are compared via @ref areClose().
* Members must be comparable via operator ==.
*/
template <typename R>
typename EnableIf<sizeof(((const R*)(0U))->size()) && sizeof((*((const R*)(0U)))[0]), bool>::Type
operator==(const R& rhs) const
{
if (size() != rhs.size())
{
return false;
}
for (SizeType i = 0; i < size(); i++) // Bitset does not have iterators
{
if (!(Base::at(i) == rhs[i]))
{
return false;
}
}
return true;
}
/**
* This method compares two arrays using @ref areClose(), which ensures proper comparison of
* floating point values, or DSDL data structures which contain floating point fields at any depth.
* Please refer to the documentation of @ref areClose() to learn more about how it works and how to
* define custom fuzzy comparison behavior.
* Any container with size() and [] is acceptable.
*/
template <typename R>
typename EnableIf<sizeof(((const R*)(0U))->size()) && sizeof((*((const R*)(0U)))[0]), bool>::Type
isClose(const R& rhs) const
{
if (size() != rhs.size())
{