std::set<int> my_set; //inserting element in set my_set.insert(5); my_set.insert(15); my_set.insert(10); my_set.insert(7); //accessing nth element form set int x = *std::next(my_set.begin(), n);