c++ - How do I use STL algorithms with ICU's iterators? -


i wonder how use icu library iterators stl. instance, if decided output permutations of string?

with std::string looks following:

#include <iostream> #include <string> #include <algorithm>  using namespace std;  static void _usage(const char *executable) {     cout << "usage: " << executable << " <string>" << endl; }  int main (int argc, char const* argv[]) {     if (argc < 2) {         cerr << "target string expected" << endl;         _usage(argv[0]);         return 1;     }      string s(argv[1]);      {         cout << s << endl;     } while (next_permutation(s.begin(), s.end()));      return 0; } 

i tried same using icu:

#include <unicode/unistr.h> #include <unicode/uchriter.h> #include <unicode/ustdio.h> #include <algorithm> #include <string> #include <iostream>  using namespace std;  static void _usage(const char *executable) {     cout << "usage: " << executable << " <string>" << endl; }  int main (int argc, char const* argv[]) {     if (argc < 2) {         cerr << "target string expected" << endl;         _usage(argv[0]);         return 1;     }      unicodestring ustr(argv[1]);     uchar *uc = ustr.getbuffer(-1);      int32_t len = u_strlen(uc);     ucharcharacteriterator iter_start(uc, len);     ucharcharacteriterator iter_end(uc, len, len - 1);      {         // xxx     } while (next_permutation(iter_start, iter_end ));      return 0; } 

but fails compile:

x86_64-pc-linux-gnu-g++     -i/usr/include  -licuio -licui18n -licuuc -licudata   permute2.c   -o permute2 in file included /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4/algorithm:63:0,                  permute2.c:4: /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4/bits/stl_algo.h: in function ‘bool std::next_permutation(_biter, _biter) [with _biter = icu_49:: ucharcharacteriterator]’: permute2.c:31:49:   instantiated here /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4/bits/stl_algo.h:3531:7: error: no match ‘operator++’ in ‘++__i’ /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4/bits/stl_algo.h:3535:7: error: no match ‘operator--’ in ‘--__i’ /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4/bits/stl_algo.h:3540:4: error: no match ‘operator--’ in ‘--__i’ /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4/bits/stl_algo.h:3541:4: error: no match ‘operator*’ in ‘*__ii’ /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4/bits/stl_algo.h:3541:4: error: no match ‘operator*’ in ‘*__i’ /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4/bits/stl_algo.h:3544:8: error: no match ‘operator--’ in ‘--__j’ /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4/bits/stl_algo.h:3544:8: error: no match ‘operator*’ in ‘*__i’ ... 

what's proper way make use of stl icu? extend ucharcharacteriterator class , provide code these operators?


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -