mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 14:49:53 +08:00
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:
parent
cc05b1df52
commit
010b16510f
@ -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
|
||||
|
||||
@ -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)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user