diff --git a/media/codec2/vndk/util/C2InterfaceUtils.cpp b/media/codec2/vndk/util/C2InterfaceUtils.cpp index 61ec9115be..0c1729b69a 100644 --- a/media/codec2/vndk/util/C2InterfaceUtils.cpp +++ b/media/codec2/vndk/util/C2InterfaceUtils.cpp @@ -216,9 +216,14 @@ C2SupportedFlags C2SupportedFlags::limitedTo(const C2SupportedFlags &li if (limit.contains(minMask) && contains(minMask)) { values[0] = minMask; // keep only flags that are covered by limit - std::remove_if(values.begin(), values.end(), [&limit, minMask](const C2Value::Primitive &v) -> bool { - T value = v.ref() | minMask; - return value == minMask || !limit.contains(value); }); + values.erase(std::remove_if(values.begin(), values.end(), + [&limit, minMask]( + const C2Value::Primitive &v) -> bool { + T value = v.ref() | minMask; + return value == minMask || + !limit.contains(value); + }), + values.end()); // we also need to do it vice versa for (const C2Value::Primitive &v : _mValues) { T value = v.ref() | minMask; @@ -264,24 +269,33 @@ bool C2SupportedValueSet::contains(T value) const { template C2SupportedValueSet C2SupportedValueSet::limitedTo(const C2SupportedValueSet &limit) const { std::vector values = _mValues; // make a copy - std::remove_if(values.begin(), values.end(), [&limit](const C2Value::Primitive &v) -> bool { - return !limit.contains(v.ref()); }); + values.erase(std::remove_if(values.begin(), values.end(), + [&limit](const C2Value::Primitive &v) -> bool { + return !limit.contains(v.ref()); + }), + values.end()); return C2SupportedValueSet(std::move(values)); } template C2SupportedValueSet C2SupportedValueSet::limitedTo(const C2SupportedRange &limit) const { std::vector values = _mValues; // make a copy - std::remove_if(values.begin(), values.end(), [&limit](const C2Value::Primitive &v) -> bool { - return !limit.contains(v.ref()); }); + values.erase(std::remove_if(values.begin(), values.end(), + [&limit](const C2Value::Primitive &v) -> bool { + return !limit.contains(v.ref()); + }), + values.end()); return C2SupportedValueSet(std::move(values)); } template C2SupportedValueSet C2SupportedValueSet::limitedTo(const C2SupportedFlags &limit) const { std::vector values = _mValues; // make a copy - std::remove_if(values.begin(), values.end(), [&limit](const C2Value::Primitive &v) -> bool { - return !limit.contains(v.ref()); }); + values.erase(std::remove_if(values.begin(), values.end(), + [&limit](const C2Value::Primitive &v) -> bool { + return !limit.contains(v.ref()); + }), + values.end()); return C2SupportedValueSet(std::move(values)); }