我想确定向量中是否存在重复项。这里最好的选择是什么?
sort(arrLinkToClients.begin(), arrLinkToClients.end(), [&](const type1& lhs,const type1& rhs)
{
lhs.nTypeOfLink < rhs.nTypeOfLink;
});
auto it = unique(arrLinkToClients.begin(), arrLinkToClients.end(), [&](const type1& lhs, const type1& rhs)
{
lhs.nTypeOfLink == rhs.nTypeOfLink;
});
//how to check the iterator if there are duplicates ?
if (it)
{
//
}
Run Code Online (Sandbox Code Playgroud)