Replace raw loops with standard algorithm

This commit is contained in:
Chris Thrasher 2023-11-13 16:27:05 -07:00
parent c6919e28fc
commit c89c5eae69
3 changed files with 15 additions and 21 deletions

View File

@ -29,6 +29,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp> #include <SFML/Audio/Export.hpp>
#include <algorithm>
#include <filesystem> #include <filesystem>
#include <memory> #include <memory>
#include <vector> #include <vector>

View File

@ -63,13 +63,11 @@ template <typename T>
void SoundFileFactory::unregisterReader() void SoundFileFactory::unregisterReader()
{ {
// Remove the instance(s) of the reader from the array of factories // Remove the instance(s) of the reader from the array of factories
for (auto it = s_readers.begin(); it != s_readers.end(); /* noop */) s_readers.erase(std::remove_if(s_readers.begin(),
{ s_readers.end(),
if (it->create == &priv::createReader<T>) [](const ReaderFactory& readerFactory)
it = s_readers.erase(it); { return readerFactory.create == &priv::createReader<T>; }),
else s_readers.end());
++it;
}
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -92,13 +90,11 @@ template <typename T>
void SoundFileFactory::unregisterWriter() void SoundFileFactory::unregisterWriter()
{ {
// Remove the instance(s) of the writer from the array of factories // Remove the instance(s) of the writer from the array of factories
for (auto it = s_writers.begin(); it != s_writers.end(); /* noop */) s_writers.erase(std::remove_if(s_writers.begin(),
{ s_writers.end(),
if (it->create == &priv::createWriter<T>) [](const WriterFactory& writerFactory)
it = s_writers.erase(it); { return writerFactory.create == &priv::createWriter<T>; }),
else s_writers.end());
++it;
}
} }
} // namespace sf } // namespace sf

View File

@ -496,13 +496,10 @@ void JoystickImpl::updateConnectionsDInput()
DIEDFL_ATTACHEDONLY); DIEDFL_ATTACHEDONLY);
// Remove devices that were not connected during the enumeration // Remove devices that were not connected during the enumeration
for (auto i = joystickList.begin(); i != joystickList.end();) joystickList.erase(std::remove_if(joystickList.begin(),
{ joystickList.end(),
if (!i->plugged) [](const JoystickRecord& joystickRecord) { return !joystickRecord.plugged; }),
i = joystickList.erase(i); joystickList.end());
else
++i;
}
if (FAILED(result)) if (FAILED(result))
{ {