Create a ctype facet something like this:
#include <locale>
#include <vector>
struct dot_reader: std::ctype<char> {
dot_reader(): std::ctype<char>(get_table()) {}
static std::ctype_base::mask const* get_table() {
static std::vector<std::ctype_base::mask> rc(table_size, std::ctype_base::mask());
rc['.'] = std::ctype_base::space;
rc['\n'] = std::ctype_base::space; // probably still want \n as a separator?
return &rc[0];
}
};
Then imbue your stream with an instance of it, and read strings:
istringstream iss(sentence);
iss.imbue(locale(locale(), new dot_reader())); // Added this
copy(istream_iterator<string>(iss),
istream_iterator<string>(),
ostream_iterator<string>(cout, "\n"));