From be0b13da97121d9ca1b1d454cf3a36bcccb5173b Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Sat, 28 Sep 2024 20:18:33 -0700 Subject: Simplify `std::remove` with `std::erase` `std::erase` is a replacement for the remove-erase idiom. Changes to `OpenModeToAndroid` inadvertently revealed that the prior implementation had UB (potentially deleting the end iterator). This is now fixed. --- Source/Android/jni/AndroidCommon/AndroidCommon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Android/jni/AndroidCommon/AndroidCommon.cpp') diff --git a/Source/Android/jni/AndroidCommon/AndroidCommon.cpp b/Source/Android/jni/AndroidCommon/AndroidCommon.cpp index 25ec479790..a976d573b8 100644 --- a/Source/Android/jni/AndroidCommon/AndroidCommon.cpp +++ b/Source/Android/jni/AndroidCommon/AndroidCommon.cpp @@ -62,7 +62,7 @@ bool IsPathAndroidContent(std::string_view uri) std::string OpenModeToAndroid(std::string mode) { // The 'b' specifier is not supported by Android. Since we're on POSIX, it's fine to just skip it. - mode.erase(std::remove(mode.begin(), mode.end(), 'b')); + std::erase(mode, 'b'); if (mode == "r") return "r"; -- cgit v1.2.3