fork(3) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <locale>
  5. #include <string>
  6. #include <sstream>
  7. #include <vector>
  8.  
  9. using namespace std;
  10.  
  11. int main() {
  12. const auto temp = ctype<char>::classic_table();
  13. vector<ctype<char>::mask> bar(temp, temp + ctype<char>::table_size);
  14.  
  15. bar[' '] ^= ctype_base::space;
  16. bar['\t'] &= ~(ctype_base::space | ctype_base::cntrl);
  17. bar[':'] |= ctype_base::space;
  18.  
  19. istringstream foo("lorem\tipsum\nlorem ipsum:lorem-ipsum");
  20.  
  21. foo.imbue(locale(cin.getloc(), new ctype<char>(bar.data())));
  22.  
  23. for_each(istream_iterator<string>(foo), istream_iterator<string>(), [](auto i) { cout << i << endl; } );
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
lorem	ipsum
lorem ipsum
lorem-ipsum