add overload for etl::equal that compares lengths (#294)

* add overload for etl::equal that compares lengths

accoring to std::equal (https://en.cppreference.com/w/cpp/algorithm/equal)

* add test for equal overload that compares lengths
This commit is contained in:
Ivo Ihlemann 2020-10-29 10:02:44 +01:00 committed by GitHub
parent cc05b1df52
commit 010b16510f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -800,6 +800,19 @@ namespace etl
}
#endif
template <typename TIterator1, typename TIterator2>
ETL_NODISCARD
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2)
{
if (etl::distance(first1, last1) !=
etl::distance(first2, last2))
{
return false;
}
return etl::equal(first1, last1, first2);
}
#if ETL_NOT_USING_STL
//***************************************************************************
// lexicographical_compare

View File

@ -703,6 +703,10 @@ namespace
{
CHECK(etl::equal(std::begin(dataV), std::end(dataV), std::begin(dataL)));
CHECK(!etl::equal(std::begin(dataSL), std::end(dataSL), std::begin(dataL)));
int small[] = { dataS[0] };
CHECK(etl::equal(std::begin(dataV), std::end(dataV), std::begin(dataL), std::end(dataL)));
CHECK(!etl::equal(std::begin(dataS), std::end(dataS), std::begin(small), std::end(small)));
}
//*************************************************************************