Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[C++] Custom stream delimiters
struct delimiter_ctype : std::ctype<char> {
static const mask* make_table(std::string delims)
{
// make a copy of the "C" locale table
static std::vector<mask> v(classic_table(), classic_table() + table_size);
for(mask m : v){
m &= ~space;
}
for(char d : delims){
v[d] |= space;
}
return &v[0];
}
delimiter_ctype(std::string delims, ::size_t refs = 0) : ctype(make_table(delims), false, refs) {}
};
void foo(){
std::string line;
std::stringstream ssline;
ssline.imbue(std::locale(ssline.getloc(),new delimiter_ctype(",")));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.