unconst is a small help that converts a const iterator to a non-const iterator with the help of the container. Currently it is using the boost iterator/range libraries. Convert it to <ranges> as part of an effort to standardize on a single range library. Its only user in mutation_partition is converted as well. Due to more iteroperability problems between <range> and boost, some calls to boost::adaptors::reversed have to be converted as well.
27 lines
515 B
C++
27 lines
515 B
C++
/*
|
|
* Copyright (C) 2014-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <ranges>
|
|
|
|
template <typename Container>
|
|
std::ranges::range auto
|
|
unconst(Container& c, std::ranges::range auto&& r) {
|
|
return std::ranges::subrange(
|
|
c.erase(r.begin(), r.begin()),
|
|
c.erase(r.end(), r.end())
|
|
);
|
|
}
|
|
|
|
template <typename Container>
|
|
typename Container::iterator
|
|
unconst(Container& c, typename Container::const_iterator i) {
|
|
return c.erase(i, i);
|
|
}
|