Код: Выделить всё
#include
#include
int main()
{
std::vector v {1, 2, 1, 1, 3, 3, 3, 4, 5, 4};
fmt::println ("{}", v);
// [1, 2, 1, 1, 3, 3, 3, 4, 5, 4]
const auto ret = std::ranges::unique(v);
v.erase(ret.begin(), ret.end());
fmt::println ("{}", v);
// [1, 2, 1, 3, 4, 5, 4]
}
Код: Выделить всё
auto vw = v | skip_adjacent_items;
fmt::println ("{}", vw);
// [1, 2, 1, 3, 4, 5, 4]
Самое близкое, что я вижу, это std::views::filter, но он фильтрует элемент независимо от предыдущего итерированного элемента.>
Подробнее здесь: https://stackoverflow.com/questions/798 ... cent-items