ftl: delegate SmallVector<const T> to std::vector<T>
An STL container of const T uses std::allocator<const T>, which was
an undocumented libc++ extension that has been removed. See
llvm.org/PR96319.
Bug: http://b/349681543
Test: ftl_test
Change-Id: Ic5ef8b80231bd58b77e5ca0ee48f263b03973a3f
diff --git a/include/ftl/small_vector.h b/include/ftl/small_vector.h
index 43e9fac..3d5d52e 100644
--- a/include/ftl/small_vector.h
+++ b/include/ftl/small_vector.h
@@ -234,7 +234,7 @@
}
// Extracts the elements as std::vector.
- std::vector<T> promote() && {
+ std::vector<std::remove_const_t<T>> promote() && {
if (dynamic()) {
return std::get<Dynamic>(std::move(vector_)).promote();
} else {
@@ -290,11 +290,11 @@
class SmallVector<T, 0> final : details::ArrayTraits<T>,
details::ArrayComparators<SmallVector>,
details::ArrayIterators<SmallVector<T, 0>, T>,
- std::vector<T> {
+ std::vector<std::remove_const_t<T>> {
using details::ArrayTraits<T>::replace_at;
using Iter = details::ArrayIterators<SmallVector, T>;
- using Impl = std::vector<T>;
+ using Impl = std::vector<std::remove_const_t<T>>;
friend Iter;
@@ -394,12 +394,12 @@
pop_back();
}
- std::vector<T> promote() && { return std::move(*this); }
+ std::vector<std::remove_const_t<T>> promote() && { return std::move(*this); }
private:
template <typename U, std::size_t M>
static Impl convert(SmallVector<U, M>&& other) {
- if constexpr (std::is_constructible_v<Impl, std::vector<U>&&>) {
+ if constexpr (std::is_constructible_v<Impl, std::vector<std::remove_const_t<U>>&&>) {
return std::move(other).promote();
} else {
SmallVector vector(other.size());