Modernize std::all_of with ranges
In DITSpecification.cpp, MaterialAsset.cpp, and ShaderAsset.cpp, lambda predicates were replaced by pointers to member functions because ranges algorithms are able invoke those. In NetPlayClient.cpp, the non-trivial `NetPlay::Player` elements were being passed by value in `NetPlayClient::DoAllPlayersHaveGame()`. This has been fixed. In WIABlob.cpp, the second example's predicate was returning the `std::optional` by value instead of implicitly converting it to a bool. This has been fixed.
This commit is contained in:
1 parent
826e2bbf98
commit
860e6cf5cb
27 files changed
+42
-51
No files matched your search
@@ -1060,14 +1060,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
||||
{
|
||||
// we have all records for this frame
|
||||
|
||||
if (!std::all_of(timebases.begin(), timebases.end(), [&](std::pair<PlayerId, u64> pair) {
|
||||
if (!std::ranges::all_of(timebases, [&](std::pair<PlayerId, u64> pair) {
|
||||
return pair.second == timebases[0].second;
|
||||
}))
|
||||
{
|
||||
int pid_to_blame = 0;
|
||||
for (auto pair : timebases)
|
||||
{
|
||||
if (std::all_of(timebases.begin(), timebases.end(), [&](std::pair<PlayerId, u64> other) {
|
||||
if (std::ranges::all_of(timebases, [&](std::pair<PlayerId, u64> other) {
|
||||
return other.first == pair.first || other.second != pair.second;
|
||||
}))
|
||||
{
|
||||
@@ -1467,14 +1467,12 @@ bool NetPlayServer::SetupNetSettings()
|
||||
|
||||
bool NetPlayServer::DoAllPlayersHaveIPLDump() const
|
||||
{
|
||||
return std::all_of(m_players.begin(), m_players.end(),
|
||||
[](const auto& p) { return p.second.has_ipl_dump; });
|
||||
return std::ranges::all_of(m_players, [](const auto& p) { return p.second.has_ipl_dump; });
|
||||
}
|
||||
|
||||
bool NetPlayServer::DoAllPlayersHaveHardwareFMA() const
|
||||
{
|
||||
return std::all_of(m_players.begin(), m_players.end(),
|
||||
[](const auto& p) { return p.second.has_hardware_fma; });
|
||||
return std::ranges::all_of(m_players, [](const auto& p) { return p.second.has_hardware_fma; });
|
||||
}
|
||||
|
||||
struct SaveSyncInfo
|
||||
|
||||
Reference in new issue
Block a user