#include <set>
#include <list>
#include <string>
#include <iostream>

using namespace std;

int main() {

	// set prevents dupes, list preserves order
	set<string> theset;
	list<set<string>::iterator> thelist;
	
	// insertion is like this:
	auto insert = [&] (const string &str) {
		auto inserted = theset.insert(str);
		if (inserted.second)
			thelist.push_back(inserted.first);
	};

	// then, for example:
	insert("zebra");       // first zebra
	insert("chair a");     // first chair a
	insert("desk");        // first desk
	insert("desk");
	insert("chair b");     // first chair b
	insert("chair a");
	insert("chair a");
	insert("table");       // first table
	insert("chair a");
	insert("xylophone");   // first xylophone
	insert("zebra");
	
	// access can be done like:
	for (auto istr : thelist)
		cout << *istr << endl;
	
}