mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-02 12:28:06 +01:00
fix(HostEntry): preserve order of addresses and aliases (fixes #3807)
This commit is contained in:
parent
8119259c89
commit
c624b27878
@ -76,13 +76,6 @@ public:
|
||||
/// for the host.
|
||||
|
||||
private:
|
||||
template <typename C>
|
||||
void removeDuplicates(C& list)
|
||||
{
|
||||
std::sort(list.begin(), list.end());
|
||||
auto last = std::unique(list.begin(), list.end());
|
||||
list.erase(last, list.end());
|
||||
}
|
||||
|
||||
std::string _name;
|
||||
AliasList _aliases;
|
||||
|
@ -15,12 +15,25 @@
|
||||
#include "Poco/Net/HostEntry.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
template <typename T>
|
||||
void removeDuplicates(std::vector<T>& list)
|
||||
{
|
||||
std::set<T> uniqueValues;
|
||||
// Remove duplicates and preserve order
|
||||
list.erase(
|
||||
std::remove_if(list.begin(), list.end(), [&uniqueValues](const T& value) { return !uniqueValues.insert(value).second; }),
|
||||
list.end()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
HostEntry::HostEntry()
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user