collate.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See
  5. // accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. #include <iostream>
  9. #include <string>
  10. #include <set>
  11. #include <boost/locale.hpp>
  12. using namespace std;
  13. using namespace boost::locale;
  14. int main()
  15. {
  16. generator gen;
  17. std::locale::global(gen(""));
  18. /// Set global locale to requested
  19. /// Create a set that includes all strings sorted according to ABC order
  20. /// std::locale can be used as object for comparison
  21. typedef std::set<std::string,std::locale> set_type;
  22. set_type all_strings;
  23. /// Read all strings into the set
  24. while(!cin.eof()) {
  25. std::string tmp;
  26. getline(cin,tmp);
  27. all_strings.insert(tmp);
  28. }
  29. /// Print them out
  30. for(set_type::iterator p=all_strings.begin();p!=all_strings.end();++p) {
  31. cout<<*p<<endl;
  32. }
  33. }
  34. // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4