diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index d6b144d5..c52d445c 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -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::value) + if ETL_IF_CONSTEXPR(etl::is_bidirectional_iterator_concept::value) { return private_algorithm::rotate_right_by_one(first, last); }