为什么unique排序后 某些元素被置为空了

正文描述 正文描述 正文描述 正文描述 正文描述 正文描述 正文描述 正文描述 正文描述 正文描述

img

#include<iostream>
#include<string>
#include<deque>
#include<vector>
#include<stack>
#include<algorithm>
#include<list>
#include<numeric>
#include<iterator>
using std::cout; using std::endl; using std::cin; using std::string; using std::deque; using std::stack;
using std::vector; using std::count; using std::find; using std::list; using std::accumulate;

void elimDups(vector<string>& words) {
    std::sort(words.begin(), words.end());
    for (const auto& word : words)cout << word << " ";
    cout << endl;
    cout << words.size() <<"\n"<< endl;

    auto it = std::unique(words.begin(), words.end());
    for (const string& word : words)cout << word << endl;
    cout << words.size() << "\n" << endl;
    
    words.erase(it, words.end());
    for (const string& word : words)cout << word << " ";
    cout << endl;
    cout << words.size() << endl;

}

int main() {


    vector<string>words{ "test","test","next","next","num","num","four","four","x","x","x","x" };
    elimDups(words);


    system("pause");

    return 0;
}