1//
2// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3//
4// Distributed under the Boost Software License, Version 1.0.
5// https://www.boost.org/LICENSE_1_0.txt
6
7#include <boost/locale.hpp>
8#include <iostream>
9#include <set>
10#include <string>
11#include <vector>
12
13using namespace boost::locale;
14
15int main(int argc, char** argv)
16{
17 if(argc != 3) {
18 std::cerr << "Usage backend locale\n";
19 return 1;
20 } else {
21 boost::locale::localization_backend_manager mgr = boost::locale::localization_backend_manager::global();
22 mgr.select(backend_name: argv[1]);
23 generator gen(mgr);
24 // Set global locale to requested
25 std::locale::global(loc: gen(argv[2]));
26 }
27
28 // Read all strings into a vector
29 std::vector<std::string> all;
30 while(!std::cin.eof()) {
31 std::string tmp;
32 std::getline(is&: std::cin, str&: tmp);
33 all.push_back(x: tmp);
34 }
35 for(int i = 0; i < 10000; i++) {
36 std::vector<std::string> tmp = all;
37 // std::locale can be used as object for comparison
38 std::sort(first: tmp.begin(), last: tmp.end(), comp: std::locale());
39 if(i == 0) {
40 for(const auto& s : tmp)
41 std::cout << s << std::endl;
42 }
43 }
44}
45

source code of boost/libs/locale/examples/performance/perf_collate.cpp