mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-03 12:58:03 +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.
|
/// for the host.
|
||||||
|
|
||||||
private:
|
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;
|
std::string _name;
|
||||||
AliasList _aliases;
|
AliasList _aliases;
|
||||||
|
@ -15,12 +15,25 @@
|
|||||||
#include "Poco/Net/HostEntry.h"
|
#include "Poco/Net/HostEntry.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Net {
|
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()
|
HostEntry::HostEntry()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user