0

Reland "[base] Update Erase()/EraseIf() calls for std::vector<> in misc files"

This is a reland of commit 98f692f99b

Original change's description:
> [base] Update Erase()/EraseIf() calls for std::vector<> in misc files
>
> They're now replaced with C++20 std::erase()/std::erase_if().
>
> Script:
> ```
> * extract files referencing Erase()/EraseIf() on cs via css selectors *
>
> 1. Run sed replacements:
> 's/base::EraseIf/std::erase_if/g'
> 's/base::Erase/std::erase/g'
> 's/#include "b/c/cxx20_erase.h"/#include <vector>/g'
> 's/#include "b/c/cxx20_erase_vector.h"/#include <vector>/g'
>
> 2. Run git cl format to sieve <vector> include upwards
> 3. Run sed with -z to separate <vector> include from quoted includes
> (above and below)
>
> 's/\n\n#include <vector>\n/\n#include <vector>\n\n/g'
> 's/"\n#include <vector>/"\n\n#include <vector>/g'
>
> 4. Run sed with -z to force <vector> includes on the remaining files:
>
> 's/#include <(\w+)>/#include <\1>\n#include <vector>/g'
>
> 5. Run git cl format to collapse duplicate <vector> includes
>
> 6. Fix outliers by hand :)
> ```
>
> Bug: 40256229
> Change-Id: I003c7c750afbff4e1710990f438567640b753287
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5331992
> Auto-Submit: Andrew Rayskiy <greengrape@google.com>
> Owners-Override: Peter Kasting <pkasting@chromium.org>
> Reviewed-by: Peter Kasting <pkasting@chromium.org>
> Commit-Queue: Andrew Rayskiy <greengrape@google.com>
> Cr-Commit-Position: refs/heads/main@{#1268370}

Bug: 40256229
Change-Id: Ic6bb42c33586ad47a5d6504e410e458b9be53d96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5345270
Commit-Queue: Andrew Rayskiy <greengrape@google.com>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Owners-Override: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1268542}
This commit is contained in:
Andrew Rayskiy
2024-03-05 17:53:36 +00:00
committed by Chromium LUCI CQ
parent 6ac3ec4405
commit dae52e96a5
53 changed files with 89 additions and 99 deletions
ash
base
chrome
chromecast
chromeos
ash
services
libassistant
printing
components
content
device/fido/mac
ios/chrome/browser
segmentation_platform
ui
settings
password
media/mojo/services
net/http
services/network
ui

@ -14,7 +14,6 @@
#include "ash/birch/birch_weather_provider.h"
#include "ash/constants/ash_features.h"
#include "ash/shell.h"
#include "base/containers/cxx20_erase_vector.h"
#include "base/functional/callback_forward.h"
#include "base/time/time.h"
@ -151,7 +150,7 @@ std::vector<std::unique_ptr<BirchItem>> BirchModel::GetItemsForDisplay() {
std::vector<std::unique_ptr<BirchItem>> all_items = GetAllItems();
// Remove any items with no ranking.
base::EraseIf(all_items, [](const auto& item) {
std::erase_if(all_items, [](const auto& item) {
return item->ranking == std::numeric_limits<float>::max();
});

@ -47,7 +47,7 @@ class TestArcResizeLockPrefDelegate : public ArcResizeLockPrefDelegate {
if (is_needed)
confirmation_needed_app_ids_.push_back(app_id);
else
base::Erase(confirmation_needed_app_ids_, app_id);
std::erase(confirmation_needed_app_ids_, app_id);
}
int GetShowSplashScreenDialogCount() const override { return show_count_; }

@ -370,7 +370,7 @@ class TestObserver : public DesksController::Observer {
EXPECT_TRUE(DesksController::Get()->AreDesksBeingModified());
}
void OnDeskRemoved(const Desk* desk) override {
base::Erase(desks_, desk);
std::erase(desks_, desk);
EXPECT_TRUE(DesksController::Get()->AreDesksBeingModified());
}
void OnDeskActivationChanged(const Desk* activated,

@ -9,7 +9,6 @@
#include "ash/test/ash_test_base.h"
#include "ash/wm/overview/overview_delegate.h"
#include "base/containers/cxx20_erase.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/memory/raw_ptr.h"
#include "ui/aura/window.h"
@ -46,7 +45,7 @@ class TestOverviewDelegate : public OverviewDelegate {
}
void RemoveAndDestroyExitAnimationObserver(
DelayedAnimationObserver* animation_observer) override {
base::EraseIf(observers_, base::MatchesUniquePtr(animation_observer));
std::erase_if(observers_, base::MatchesUniquePtr(animation_observer));
}
void AddEnterAnimationObserver(
std::unique_ptr<DelayedAnimationObserver> animation_observer) override {}

@ -10,7 +10,6 @@
#include "ash/test/ash_test_base.h"
#include "ash/wm/overview/overview_delegate.h"
#include "base/containers/cxx20_erase.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/test/task_environment.h"
#include "ui/aura/window.h"
@ -39,7 +38,7 @@ class TestOverviewDelegate : public OverviewDelegate {
}
void RemoveAndDestroyExitAnimationObserver(
DelayedAnimationObserver* animation_observer) override {
base::EraseIf(exit_observers_, base::MatchesUniquePtr(animation_observer));
std::erase_if(exit_observers_, base::MatchesUniquePtr(animation_observer));
}
void AddEnterAnimationObserver(
std::unique_ptr<DelayedAnimationObserver> animation_observer) override {
@ -48,7 +47,7 @@ class TestOverviewDelegate : public OverviewDelegate {
}
void RemoveAndDestroyEnterAnimationObserver(
DelayedAnimationObserver* animation_observer) override {
base::EraseIf(enter_observers_, base::MatchesUniquePtr(animation_observer));
std::erase_if(enter_observers_, base::MatchesUniquePtr(animation_observer));
}
size_t num_exit_observers() const { return exit_observers_.size(); }

@ -5721,7 +5721,7 @@ TEST_F(TabletModeOverviewSessionTest, WindowDestroyWhileScrolling) {
}
// Delete one of the windows.
base::Erase(windows, windows[2]);
std::erase(windows, windows[2]);
// Continue scrolling and then end the scroll. There should be no crash.
for (int i = 0; i < 10; ++i) {

@ -1308,11 +1308,9 @@ void FieldTrialList::RemoveObserverInternal(Observer* observer,
return;
}
AutoLock auto_lock(global_->lock_);
if (include_low_anonymity) {
Erase(global_->observers_including_low_anonymity_, observer);
} else {
Erase(global_->observers_, observer);
}
std::erase(include_low_anonymity ? global_->observers_including_low_anonymity_
: global_->observers_,
observer);
DCHECK_EQ(global_->num_ongoing_notify_field_trial_group_selection_calls_, 0)
<< "Cannot call RemoveObserver while accessing FieldTrial::group_name().";
}

@ -17,7 +17,6 @@
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/cxx20_erase_vector.h"
#include "base/dcheck_is_on.h"
#include "base/debug/dump_without_crashing.h"
#include "base/notreached.h"
@ -343,7 +342,7 @@ class ObserverList {
// Compact() is only ever called when the last iterator is destroyed.
DETACH_FROM_SEQUENCE(iteration_sequence_checker_);
base::EraseIf(observers_,
std::erase_if(observers_,
[](const auto& o) { return o.IsMarkedForRemoval(); });
}

@ -20,7 +20,6 @@
#include <unordered_set>
#include <vector>
#include "base/containers/cxx20_erase_vector.h"
#include "base/containers/queue.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -229,7 +228,7 @@ TEST(Erase, IsNotIn) {
std::vector<int> lhs = {0, 2, 2, 4, 4, 4, 6, 8, 10};
std::vector<int> rhs = {1, 2, 2, 4, 5, 6, 7};
std::vector<int> expected = {2, 2, 4, 6};
EXPECT_EQ(5u, EraseIf(lhs, IsNotIn<std::vector<int>>(rhs)));
EXPECT_EQ(5u, std::erase_if(lhs, IsNotIn<std::vector<int>>(rhs)));
EXPECT_EQ(expected, lhs);
}

@ -240,7 +240,7 @@ void PrintTo(const Bucket& value, std::ostream* os);
template <typename BucketArray>
auto BucketsAreArray(BucketArray buckets) {
auto non_empty_buckets = buckets;
EraseIf(non_empty_buckets, [](Bucket b) { return b.count == 0; });
std::erase_if(non_empty_buckets, [](Bucket b) { return b.count == 0; });
return ::testing::UnorderedElementsAreArray(non_empty_buckets);
}

@ -10,7 +10,6 @@
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/containers/cxx20_erase_vector.h"
#include "base/containers/flat_map.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial_param_associator.h"
@ -542,7 +541,7 @@ void ScopedFeatureList::InitWithMergedFeatures(
// set through |merged_features.enabled_feature_list|. In this case,
// FieldTrialParamAssociator::AssociateFieldTrialParams() will fail.
// So remove such field trials from |all_states| here.
EraseIf(all_states, [feature](const auto& state) {
std::erase_if(all_states, [feature](const auto& state) {
return state.trial_name == feature.StudyNameOrDefault();
});

@ -9,7 +9,6 @@
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/containers/cxx20_erase.h"
#include "base/memory/singleton.h"
#include "base/strings/string_util.h"
#include "base/trace_event/heap_profiler_allocation_context_tracker.h" // no-presubmit-check
@ -62,7 +61,7 @@ void ThreadIdNameManager::AddObserver(Observer* obs) {
void ThreadIdNameManager::RemoveObserver(Observer* obs) {
AutoLock locked(lock_);
DCHECK(base::Contains(observers_, obs));
base::Erase(observers_, obs);
std::erase(observers_, obs);
}
void ThreadIdNameManager::SetName(const std::string& name) {

@ -19,7 +19,6 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/containers/cxx20_erase_vector.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"

@ -15,7 +15,6 @@
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/checked_iterators.h"
#include "base/containers/cxx20_erase_vector.h"
#include "base/containers/map_util.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
@ -1182,7 +1181,7 @@ Value::List::iterator Value::List::Insert(const_iterator pos, Value&& value) {
}
size_t Value::List::EraseValue(const Value& value) {
return Erase(storage_, value);
return std::erase(storage_, value);
}
size_t Value::List::EstimateMemoryUsage() const {

@ -22,7 +22,6 @@
#include "base/bit_cast.h"
#include "base/compiler_specific.h"
#include "base/containers/checked_iterators.h"
#include "base/containers/cxx20_erase_vector.h"
#include "base/containers/flat_map.h"
#include "base/containers/span.h"
#include "base/memory/raw_ref.h"
@ -775,7 +774,7 @@ class BASE_EXPORT GSL_OWNER Value {
// Erases all values for which `predicate` evaluates to true from this list.
template <typename Predicate>
size_t EraseIf(Predicate predicate) {
return base::EraseIf(storage_, predicate);
return std::erase_if(storage_, predicate);
}
// Estimates dynamic memory usage. Requires tracing support

@ -4,6 +4,8 @@
#include "chrome/browser/ash/app_list/arc/arc_app_test.h"
#include <vector>
#include "ash/components/arc/arc_util.h"
#include "ash/components/arc/mojom/app.mojom-shared.h"
#include "ash/components/arc/session/arc_bridge_service.h"
@ -17,7 +19,6 @@
#include "ash/constants/ash_features.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/cxx20_erase.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/ranges/algorithm.h"
@ -397,7 +398,7 @@ void ArcAppTest::UpdatePackage(arc::mojom::ArcPackageInfoPtr updated_package) {
}
void ArcAppTest::RemovePackage(const std::string& package_name) {
base::EraseIf(fake_packages_, [package_name](const auto& package) {
std::erase_if(fake_packages_, [package_name](const auto& package) {
return package->package_name == package_name;
});
}

@ -16,7 +16,6 @@
#include "ash/public/cpp/keyboard/keyboard_switches.h"
#include "ash/wm/tablet_mode/tablet_mode_controller_test_api.h"
#include "base/containers/contains.h"
#include "base/containers/cxx20_erase.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
@ -138,7 +137,7 @@ class TestInputMethodManager : public im::MockInputMethodManager {
}
void RemoveEnabledInputMethodId(const std::string& ime_id) {
base::EraseIf(enabled_input_method_ids_,
std::erase_if(enabled_input_method_ids_,
[&ime_id](const std::string& id) { return id == ime_id; });
}

@ -8,7 +8,6 @@
#include <vector>
#include "base/command_line.h"
#include "base/containers/cxx20_erase.h"
#include "base/functional/bind.h"
#include "base/strings/string_util.h"
#include "chrome/browser/ash/login/existing_user_controller.h"
@ -335,7 +334,7 @@ IN_PROC_BROWSER_TEST_P(SiteIsolationFlagHandlingTest, FlagHandlingTest) {
// Remove flag sentinels. Keep whatever is between those sentinels, to
// verify that we don't pass additional parameters in there.
base::EraseIf(switches_for_user, [](const std::string& flag) {
std::erase_if(switches_for_user, [](const std::string& flag) {
return flag == "--flag-switches-begin" || flag == "--flag-switches-end";
});
EXPECT_EQ(GetParam().expected_switches_for_user, switches_for_user);

@ -4,6 +4,7 @@
#include <memory>
#include <utility>
#include <vector>
#include "ash/constants/ash_switches.h"
#include "ash/webui/media_app_ui/buildflags.h"
@ -11,7 +12,6 @@
#include "ash/webui/media_app_ui/url_constants.h"
#include "ash/webui/system_apps/public/system_web_app_type.h"
#include "base/check_deref.h"
#include "base/containers/cxx20_erase_vector.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@ -982,7 +982,7 @@ IN_PROC_BROWSER_TEST_P(MediaAppIntegrationTest, MediaAppEligibleOpenTask) {
file_manager::test::GetTasksForFile(profile(), file_path);
// Files SWA internal task "select" matches any file, we ignore it here.
base::EraseIf(result, [](auto task) {
std::erase_if(result, [](auto task) {
return task.task_descriptor.app_id == file_manager::kFileManagerSwaAppId;
});

@ -9,7 +9,6 @@
#include <vector>
#include "base/check.h"
#include "base/containers/cxx20_erase_vector.h"
#include "base/debug/dump_without_crashing.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
@ -17,9 +16,9 @@
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "chrome/browser/android/preferences/autofill/settings_launcher_helper.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/keyboard_accessory/android/manual_filling_controller.h"
#include "chrome/browser/keyboard_accessory/android/manual_filling_utils.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/vr/vr_tab_helper.h"
#include "components/autofill/content/browser/content_autofill_driver.h"
@ -435,7 +434,7 @@ CreditCardAccessoryControllerImpl::GetUnmaskedCreditCards() const {
return card_info->card.record_type() !=
CreditCard::RecordType::kVirtualCard;
};
base::EraseIf(unmasked_cards, not_virtual_card);
std::erase_if(unmasked_cards, not_virtual_card);
return unmasked_cards;
}

@ -4,6 +4,8 @@
#include "chrome/browser/notifications/notification_interactive_uitest_support.h"
#include <vector>
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
@ -227,7 +229,7 @@ void NotificationsTest::GetDisabledContentSettings(
*settings = HostContentSettingsMapFactory::GetForProfile(browser()->profile())
->GetSettingsForOneType(ContentSettingsType::NOTIFICATIONS);
base::EraseIf(*settings, [](const ContentSettingPatternSource& setting) {
std::erase_if(*settings, [](const ContentSettingPatternSource& setting) {
return setting.GetContentSetting() != CONTENT_SETTING_BLOCK ||
setting.source.compare("preference") != 0;
});

@ -9,8 +9,8 @@
#include <algorithm>
#include <memory>
#include <utility>
#include <vector>
#include "base/containers/cxx20_erase.h"
#include "base/functional/bind.h"
#include "base/i18n/rtl.h"
#include "base/memory/singleton.h"
@ -313,7 +313,7 @@ bool PluginInfoHostImpl::Context::FindEnabledPlugin(
PluginService::GetInstance()->GetPluginInfoArray(
url, mime_type, allow_wildcard, &matching_plugins, &mime_types);
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
base::EraseIf(matching_plugins, [&](const WebPluginInfo& info) {
std::erase_if(matching_plugins, [&](const WebPluginInfo& info) {
return info.path.value() == ChromeContentClient::kNotPresent;
});
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)

@ -5,7 +5,6 @@
#include <vector>
#include "base/command_line.h"
#include "base/containers/cxx20_erase.h"
#include "base/ranges/algorithm.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h"
@ -74,7 +73,7 @@ class RestoreOnStartupPolicyTest : public UrlBlockingPolicyTest,
// these tests.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
base::CommandLine::StringVector argv = command_line->argv();
base::EraseIf(argv, IsNonSwitchArgument);
std::erase_if(argv, IsNonSwitchArgument);
command_line->InitFromArgv(argv);
ASSERT_TRUE(base::ranges::equal(argv, command_line->argv()));
}

@ -4,7 +4,8 @@
#include "chrome/browser/ui/views/extensions/extensions_toolbar_interactive_uitest.h"
#include "base/containers/cxx20_erase.h"
#include <vector>
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/extensions/browsertest_util.h"
@ -176,7 +177,7 @@ ExtensionsToolbarUITest::GetToolbarActionViewsForBrowser(
std::vector<ToolbarActionView*>
ExtensionsToolbarUITest::GetVisibleToolbarActionViews() const {
auto views = GetToolbarActionViews();
base::EraseIf(views, [](views::View* view) { return !view->GetVisible(); });
std::erase_if(views, [](views::View* view) { return !view->GetVisible(); });
return views;
}

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/containers/cxx20_erase_vector.h"
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
@ -589,10 +590,10 @@ TEST_F(ChromeLabsViewControllerTest, CleanUpNewBadgePrefsTest) {
// Remove two experiments.
std::vector<LabInfo> test_experiments = TestLabInfo();
base::EraseIf(test_experiments, [](const auto& lab) {
std::erase_if(test_experiments, [](const auto& lab) {
return lab.internal_name == kFirstTestFeatureId;
});
base::EraseIf(test_experiments, [](const auto& lab) {
std::erase_if(test_experiments, [](const auto& lab) {
return lab.internal_name == kTestFeatureWithVariationId;
});

@ -11,7 +11,6 @@
#include "base/barrier_closure.h"
#include "base/containers/contains.h"
#include "base/containers/cxx20_erase.h"
#include "base/functional/bind.h"
#include "base/notreached.h"
#include "base/run_loop.h"
@ -68,7 +67,7 @@ using sync_pb::WebAppSpecifics_UserDisplayMode_UNSPECIFIED;
void RemoveWebAppFromAppsList(AppsList* apps_list,
const webapps::AppId& app_id) {
base::EraseIf(*apps_list, [app_id](const std::unique_ptr<WebApp>& app) {
std::erase_if(*apps_list, [app_id](const std::unique_ptr<WebApp>& app) {
return app->app_id() == app_id;
});
}

@ -10,9 +10,9 @@
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/containers/cxx20_erase.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@ -260,7 +260,7 @@ bool ModuleTimeDateStampGreater::operator()(
void RemoveAllowlistedEntries(
const ModuleListFilter& module_list_filter,
std::vector<third_party_dlls::PackedListModule>* blocklisted_modules) {
base::EraseIf(
std::erase_if(
*blocklisted_modules,
[&module_list_filter](const third_party_dlls::PackedListModule& module) {
return module_list_filter.IsAllowlisted(

@ -5,6 +5,7 @@
#include "chrome/test/base/browser_with_test_window_test.h"
#include <memory>
#include <vector>
#include "base/command_line.h"
#include "base/location.h"
@ -308,7 +309,7 @@ void BrowserWithTestWindowTest::SwitchActiveUser(const std::string& email) {
void BrowserWithTestWindowTest::OnProfileWillBeDestroyed(Profile* profile) {
CHECK(
base::EraseIf(profile_observations_, [profile](const auto& observation) {
std::erase_if(profile_observations_, [profile](const auto& observation) {
return observation->IsObservingSource(profile);
}));
const AccountId* account_id = ash::AnnotatedAccountId::Get(profile);

@ -44,7 +44,7 @@ ui::ElementTracker::ElementList GetTargetableEvents() {
// See ui/views/interaction/interactive_views_test.cc:330.
auto elements =
ui::ElementTracker::GetElementTracker()->GetAllElementsForTesting();
base::EraseIf(elements, [](auto* e1) {
std::erase_if(elements, [](auto* e1) {
// We must ensure to never select `kInteractiveTestPivotElementId` because
// it is an internal element of the interactive test framework. Selecting it
// will likely result in asserting in the framework.

@ -6,9 +6,9 @@
#include <memory>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/containers/cxx20_erase.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"

@ -7,8 +7,8 @@
#include <algorithm>
#include <deque>
#include <utility>
#include <vector>
#include "base/containers/cxx20_erase.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/task/single_thread_task_runner.h"

@ -9,7 +9,6 @@
#include <utility>
#include "base/command_line.h"
#include "base/containers/cxx20_erase.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
@ -183,7 +182,7 @@ class AudioCapturer : public media::AudioCapturerSource::CaptureCallback {
void RemoveObserver(assistant_client::AudioInput::Observer* observer) {
base::AutoLock lock(observers_lock_);
base::Erase(observers_, observer);
std::erase(observers_, observer);
}
int num_observers() {

@ -8,7 +8,6 @@
#include <string>
#include <vector>
#include "base/containers/cxx20_erase.h"
#include "base/strings/string_split.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -146,7 +145,7 @@ TEST(PpdLineReaderTest, SkipLongLines) {
constexpr int kMaxLineLength = 35;
std::vector<std::string> expected = base::SplitString(
kTestPpd, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
base::EraseIf(expected, [](const std::string& entry) -> bool {
std::erase_if(expected, [](const std::string& entry) -> bool {
return entry.size() > kMaxLineLength;
});
RunTest(kTestPpd, kMaxLineLength, expected);
@ -157,7 +156,7 @@ TEST(PpdLineReaderTest, SkipLongLinesGzipped) {
constexpr int kMaxLineLength = 35;
std::vector<std::string> expected = base::SplitString(
kTestPpd, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
base::EraseIf(expected, [](const std::string& entry) -> bool {
std::erase_if(expected, [](const std::string& entry) -> bool {
return entry.size() > kMaxLineLength;
});
RunTest(std::string(reinterpret_cast<const char*>(kTestPpdGzipped),

@ -8,6 +8,7 @@
#include <sys/socket.h>
#include <memory>
#include <vector>
#include "ash/session/session_controller_impl.h"
#include "ash/shelf/shelf.h"
@ -754,7 +755,7 @@ class ZAuraOutputTest : public test::ExoTestBase {
auto iter = output_holder_list_.begin();
while (iter != output_holder_list_.end()) {
auto* out_ptr = (*iter)->output.get();
bool erased = base::EraseIf(display_list,
bool erased = std::erase_if(display_list,
[out_ptr](const display::Display& display) {
return display.id() == out_ptr->id();
});

@ -4,6 +4,8 @@
#include "components/history_clusters/core/filter_cluster_processor.h"
#include <vector>
#include "base/test/metrics/histogram_tester.h"
#include "components/history_clusters/core/clustering_test_utils.h"
#include "components/history_clusters/core/config.h"
@ -159,7 +161,7 @@ TEST_F(FilterClusterProcessorTest,
// Some clusters are content visible - make sure there's at least one bit set
// properly after culling non-prominent.
base::EraseIf(clusters, [](const history::Cluster& cluster) {
std::erase_if(clusters, [](const history::Cluster& cluster) {
return !cluster.should_show_on_prominent_ui_surfaces;
});
EXPECT_FALSE(clusters.empty());

@ -4,6 +4,8 @@
#include "components/ui_devtools/ui_element.h"
#include <vector>
#include "base/memory/raw_ptr.h"
#include "components/ui_devtools/ui_devtools_unittest_utils.h"
#include "components/ui_devtools/ui_element_delegate.h"
@ -30,7 +32,7 @@ class FakeUIElementDelegate : public UIElementDelegate {
void OnUIElementReordered(UIElement* parent, UIElement* child) override {}
void OnUIElementRemoved(UIElement* ui_element) override {
base::Erase(elements_, ui_element);
std::erase(elements_, ui_element);
}
void OnUIElementBoundsChanged(UIElement* ui_element) override {}

@ -432,7 +432,7 @@ class AllowCandidateWithMasksSortedMultiOverlayProcessor
std::vector<OverlayProposedCandidate>* proposed_candidates) override {
// After sort we should only be left with candidates with rounded-display
// masks.
base::EraseIf(*proposed_candidates, [](OverlayProposedCandidate& cand) {
std::erase_if(*proposed_candidates, [](OverlayProposedCandidate& cand) {
return !cand.candidate.has_rounded_display_masks;
});

@ -92,7 +92,7 @@ class DumpAccessibilityTestBase
template <ApiTypeVector TestPasses(), ui::AXApiType::TypeConstant type>
static ApiTypeVector TestPassesExcept() {
ApiTypeVector passes = TestPasses();
base::Erase(passes, type);
std::erase(passes, type);
return passes;
}

@ -12,7 +12,6 @@
#include "base/check.h"
#include "base/check_deref.h"
#include "base/containers/cxx20_erase.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/location.h"
@ -467,8 +466,8 @@ class BackgroundSyncManagerTest
// |callback_one_shot_sync_registration_| for testing.
callback_one_shot_sync_registration_ =
std::move(one_shot_sync_registration);
base::Erase(callback_one_shot_sync_registrations_,
one_shot_sync_registration);
std::erase(callback_one_shot_sync_registrations_,
one_shot_sync_registration);
return true;
}
}
@ -499,8 +498,8 @@ class BackgroundSyncManagerTest
// |callback_periodic_sync_registration_| for testing.
callback_periodic_sync_registration_ =
std::move(periodic_sync_registration);
base::Erase(callback_periodic_sync_registrations_,
periodic_sync_registration);
std::erase(callback_periodic_sync_registrations_,
periodic_sync_registration);
return true;
}
}

@ -4,7 +4,8 @@
#include "content/browser/preloading/prefetch/prefetch_service.h"
#include "base/containers/cxx20_erase.h"
#include <vector>
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
@ -322,7 +323,7 @@ class PrefetchServiceTest : public RenderViewHostTestHarness {
std::vector<network::TestURLLoaderFactory::PendingRequest>* requests =
test_url_loader_factory_.pending_requests();
base::EraseIf(
std::erase_if(
*requests,
[](const network::TestURLLoaderFactory::PendingRequest& request) {
return !request.client.is_connected();

@ -4,8 +4,9 @@
#include "content/browser/webrtc/webrtc_webcam_browsertest.h"
#include <vector>
#include "base/command_line.h"
#include "base/containers/cxx20_erase.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "content/browser/web_contents/web_contents_impl.h"
@ -34,7 +35,7 @@ bool IsUseFakeDeviceForMediaStream(const base::CommandLine::StringType& arg) {
void RemoveFakeDeviceFromCommandLine(base::CommandLine* command_line) {
base::CommandLine::StringVector argv = command_line->argv();
base::EraseIf(argv, IsUseFakeDeviceForMediaStream);
std::erase_if(argv, IsUseFakeDeviceForMediaStream);
command_line->InitFromArgv(argv);
}

@ -10,10 +10,10 @@
#include <clocale>
#include <limits>
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/cxx20_erase.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
@ -2467,7 +2467,7 @@ class TestRunner::MainWindowTracker : public blink::WebViewObserver {
: blink::WebViewObserver(view), test_runner_(test_runner) {}
void OnDestruct() override {
EraseIf(test_runner_->main_windows_, base::MatchesUniquePtr(this));
std::erase_if(test_runner_->main_windows_, base::MatchesUniquePtr(this));
}
private:
@ -2960,7 +2960,7 @@ void TestRunner::RemoveLoadingFrame(blink::WebLocalFrame* frame) {
// flakiness due to inconsistent state management across renderers.
// See https://crbug.com/1100223 for details.
base::Erase(loading_frames_, frame);
std::erase(loading_frames_, frame);
if (!loading_frames_.empty())
return;

@ -10,13 +10,13 @@
#import <Security/Security.h>
#include <optional>
#include <vector>
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/apple/osstatus_logging.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/containers/contains.h"
#include "base/containers/cxx20_erase.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
@ -59,7 +59,7 @@ void FilterKeychainItemsByCreationDate(
std::vector<base::apple::ScopedCFTypeRef<CFDictionaryRef>>* keychain_items,
base::Time not_before,
base::Time not_after) {
base::EraseIf(
std::erase_if(
*keychain_items,
[not_before, not_after](
const base::apple::ScopedCFTypeRef<CFDictionaryRef>& attributes)

@ -6,7 +6,6 @@
#import <memory>
#import "base/containers/cxx20_erase_vector.h"
#import "base/feature_list.h"
#import "base/metrics/field_trial_params.h"
#import "base/time/time.h"

@ -10,7 +10,6 @@
#import <vector>
#import "base/containers/contains.h"
#import "base/containers/cxx20_erase.h"
#import "base/containers/flat_set.h"
#import "base/memory/raw_ptr.h"
#import "base/ranges/algorithm.h"

@ -4,7 +4,6 @@
#import "ios/chrome/browser/ui/settings/password/password_settings/password_settings_mediator.h"
#import "base/containers/cxx20_erase_vector.h"
#import "base/i18n/message_formatter.h"
#import "base/memory/raw_ptr.h"
#import "base/metrics/histogram_functions.h"

@ -6,7 +6,6 @@
#include <tuple>
#include "base/containers/cxx20_erase.h"
#include "build/build_config.h"
#include "media/base/cdm_context.h"
#include "media/cdm/cdm_helpers.h"
@ -114,7 +113,7 @@ void MojoCdmHelper::GetStorageId(uint32_t version, StorageIdCB callback) {
void MojoCdmHelper::CloseCdmFileIO(MojoCdmFileIO* cdm_file_io) {
DVLOG(3) << __func__ << ": cdm_file_io = " << cdm_file_io;
base::EraseIf(cdm_file_io_set_,
std::erase_if(cdm_file_io_set_,
[cdm_file_io](const std::unique_ptr<MojoCdmFileIO>& ptr) {
return ptr.get() == cdm_file_io;
});

@ -13,7 +13,6 @@
#include <utility>
#include <vector>
#include "base/containers/cxx20_erase.h"
#include "base/files/scoped_temp_dir.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
@ -726,7 +725,7 @@ bool ShouldIgnoreLogEntry(const NetLogEntry& entry) {
std::vector<NetLogEntry> GetFilteredNetLogEntries(
const RecordingNetLogObserver& net_log_observer) {
auto entries = net_log_observer.GetEntries();
base::EraseIf(entries, ShouldIgnoreLogEntry);
std::erase_if(entries, ShouldIgnoreLogEntry);
return entries;
}

@ -9,6 +9,7 @@
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "base/barrier_closure.h"
#include "base/base64.h"
@ -2795,7 +2796,7 @@ void NetworkContext::OnHttpCacheSizeComputed(
HttpCacheDataCounter* counter,
bool is_upper_limit,
int64_t result_or_error) {
EraseIf(http_cache_data_counters_, base::MatchesUniquePtr(counter));
std::erase_if(http_cache_data_counters_, base::MatchesUniquePtr(counter));
std::move(callback).Run(is_upper_limit, result_or_error);
}

@ -4,7 +4,8 @@
#include "ui/accessibility/ax_tree_fuzzer_util.h"
#include "base/containers/cxx20_erase_vector.h"
#include <vector>
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node.h"
#include "ui/accessibility/ax_node_data.h"
@ -163,7 +164,7 @@ void AXTreeFuzzerGenerator::RecursiveGenerateUpdate(
// To delete a node, just find the parent and update the child list to
// no longer include this node.
ui::AXNodeData parent_update = parent->data();
base::Erase(parent_update.child_ids, node->id());
std::erase(parent_update.child_ids, node->id());
tree_update.nodes.push_back(parent_update);
updated_nodes.emplace(parent_update.id);

@ -4,7 +4,8 @@
#include "ui/message_center/views/message_popup_collection.h"
#include "base/containers/cxx20_erase.h"
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
@ -47,9 +48,7 @@ class MockMessagePopupCollection : public DesktopMessagePopupCollection {
AnimationProgressed(animation());
}
void RemovePopup(MockMessagePopupView* popup) {
base::Erase(popups_, popup);
}
void RemovePopup(MockMessagePopupView* popup) { std::erase(popups_, popup); }
bool IsAnimating() { return animation()->is_animating(); }

@ -1001,7 +1001,7 @@ void ViewAXPlatformNodeDelegate::GetViewsInGroupForSet(
view_to_check->GetViewsInGroup(group_id, views_in_group);
// Remove any views that are ignored in the accessibility tree.
base::EraseIf(*views_in_group, [](View* view) {
std::erase_if(*views_in_group, [](View* view) {
return view->GetViewAccessibility().GetIsIgnored();
});
}

@ -6,7 +6,8 @@
#import <AppKit/AppKit.h>
#include "base/containers/cxx20_erase.h"
#include <vector>
#include "base/functional/bind.h"
#include "base/no_destructor.h"
#include "ui/gfx/geometry/rect.h"
@ -52,7 +53,7 @@ WindowsStationarityMonitorMac* WindowsStationarityMonitorMac::GetInstance() {
void WindowsStationarityMonitorMac::OnWidgetDestroying(Widget* widget) {
widget->RemoveObserver(this);
base::Erase(tracked_windows_, widget);
std::erase(tracked_windows_, widget);
NotifyWindowStationaryStateChanged();
}