Guard against past-end iterator in etl::rotate()

And fix scope of rotate_right_by_one for etl::rotate()
This commit is contained in:
Roland Reichwein 2026-03-08 20:45:30 +01:00
parent 74879d199b
commit 2b01bc7a94

View File

@ -1366,6 +1366,15 @@ namespace etl
ETL_CONSTEXPR14
TIterator rotate(TIterator first, TIterator middle, TIterator last)
{
if (first == middle)
{
return last;
}
if (middle == last)
{
return first;
}
if (etl::next(first) == middle)
{
return private_algorithm::rotate_left_by_one(first, last);
@ -1374,7 +1383,7 @@ namespace etl
#if ETL_USING_CPP20
if (etl::next(middle) == last)
{
if ETL_IF_CONSTEXPR(!etl::is_forward_iterator<TIterator>::value)
if ETL_IF_CONSTEXPR(etl::is_bidirectional_iterator_concept<TIterator>::value)
{
return private_algorithm::rotate_right_by_one(first, last);
}