Skip to content

Commit 6ed1209

Browse files
committed
Simplify more std::remove_if calls just checking for null
1 parent 5798230 commit 6ed1209

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

samples/learn/DroidData.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ std::optional<std::vector<std::shared_ptr<object::Character>>> Droid::getFriends
5555
[](const auto& wpFriend) noexcept {
5656
return make_hero(wpFriend);
5757
});
58-
result.erase(std::remove_if(result.begin(),
59-
result.end(),
60-
[](const auto& entry) noexcept {
61-
return !entry;
62-
}),
58+
result.erase(std::remove(result.begin(), result.end(), std::shared_ptr<object::Character> {}),
6359
result.end());
6460

6561
return result.empty() ? std::nullopt : std::make_optional(std::move(result));

samples/learn/HumanData.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ std::optional<std::vector<std::shared_ptr<object::Character>>> Human::getFriends
5454
[](const auto& wpFriend) noexcept {
5555
return make_hero(wpFriend);
5656
});
57-
result.erase(std::remove_if(result.begin(),
58-
result.end(),
59-
[](const auto& entry) noexcept {
60-
return !entry;
61-
}),
57+
result.erase(std::remove(result.begin(), result.end(), std::shared_ptr<object::Character> {}),
6258
result.end());
6359

6460
return result.empty() ? std::nullopt : std::make_optional(std::move(result));

0 commit comments

Comments
 (0)