#include <algorithm>
#include <iostream>
#include <iterator>
#include <locale>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
int main() {
const auto temp = ctype<char>::classic_table();
vector<ctype<char>::mask> bar(temp, temp + ctype<char>::table_size);
bar[' '] ^= ctype_base::space;
bar['\t'] &= ~(ctype_base::space | ctype_base::cntrl);
bar[':'] |= ctype_base::space;
istringstream foo("lorem\tipsum\nlorem ipsum:lorem-ipsum");
foo.imbue(locale(cin.getloc(), new ctype<char>(bar.data())));
for_each(istream_iterator<string>(foo), istream_iterator<string>(), [](auto i) { cout << i << endl; } );
return 0;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDxsb2NhbGU+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxzc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewoJY29uc3QgYXV0byB0ZW1wID0gY3R5cGU8Y2hhcj46OmNsYXNzaWNfdGFibGUoKTsKCXZlY3RvcjxjdHlwZTxjaGFyPjo6bWFzaz4gYmFyKHRlbXAsIHRlbXAgKyBjdHlwZTxjaGFyPjo6dGFibGVfc2l6ZSk7CgkKCWJhclsnICddIF49IGN0eXBlX2Jhc2U6OnNwYWNlOwoJYmFyWydcdCddICY9IH4oY3R5cGVfYmFzZTo6c3BhY2UgfCBjdHlwZV9iYXNlOjpjbnRybCk7CgliYXJbJzonXSB8PSBjdHlwZV9iYXNlOjpzcGFjZTsKCQoJaXN0cmluZ3N0cmVhbSBmb28oImxvcmVtXHRpcHN1bVxubG9yZW0gaXBzdW06bG9yZW0taXBzdW0iKTsKCQoJZm9vLmltYnVlKGxvY2FsZShjaW4uZ2V0bG9jKCksIG5ldyBjdHlwZTxjaGFyPihiYXIuZGF0YSgpKSkpOwoJCglmb3JfZWFjaChpc3RyZWFtX2l0ZXJhdG9yPHN0cmluZz4oZm9vKSwgaXN0cmVhbV9pdGVyYXRvcjxzdHJpbmc+KCksIFtdKGF1dG8gaSkgeyBjb3V0IDw8IGkgPDwgZW5kbDsgfSApOwoJCglyZXR1cm4gMDsKfQ==