これまでのところ、私はこの機能を持っています:
std::vector<int> f(std::vector& v)
{
std::vector<int> result;
for(unsigned x = 0; x < v.size(); x++)
{
std::vector<int>::iterator location = std::find(result.begin(),result.end(),v[x]);
if(location == result.end())
{
result.push_back(this->v[x]);
}
}
std::sort(result.begin(),result.end());
return result;
}
この関数は、重複のない v から要素の並べ替えられたベクトルを返します。
これをもっとコンパクトに書く方法はありますか?私はstd::uniqueについて読んだことがありますが、これには私ができないベクトルの編集が含まれます。