#include <iostream>
#include <vector>
#include <locale>
#include <sstream>
 
// This ctype facet classifies .^:;\n but not anything else as whitespace
struct my_whitespace : std::ctype<char> {
    static const mask* make_table()
    {
        // make a copy of the "C" locale table
        static std::vector<mask> v(classic_table(),  classic_table() + table_size);
        // these will be whitespace
        v['.'] |=  space; 
        v['^'] |=  space; 
        v[':'] |=  space; 
        v[';'] |=  space; 
        // space and tab won't be whitespace
        v[' '] &= ~space;
        v['\t'] &= ~space;
        return &v[0];
    }
    my_whitespace(std::size_t refs = 0) :
        std::ctype<char>(make_table(), false, refs) {}
};
 
int main()
{
    std::string in = "a:b.c;d\ne^f";
 
    std::istringstream s(in);
    s.imbue(std::locale(s.getloc(), new my_whitespace()));

    std::string token;
    while(s >> token)
        std::cout << "  " << token<< '\n';
}