Last active
September 28, 2015 09:03
-
-
Save yohhoy/fa72e6cd4eb0b8071f64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <locale> | |
#include <string> | |
#include <sstream> | |
#include <iostream> | |
#include <vector> | |
struct tsv_ctype : std::ctype<char> { | |
static const mask* make_table() | |
{ | |
static std::vector<mask> lut(classic_table(), classic_table() + table_size); | |
lut[' '] &= ~space; | |
return &lut[0]; | |
} | |
explicit tsv_ctype(std::size_t refs = 0) | |
: ctype(make_table(), false, refs) {} | |
}; | |
int main () | |
{ | |
std::istringstream iss ("123\tHello world\t3.14"); | |
int a; | |
std::string b; | |
float c; | |
iss.imbue(std::locale(iss.getloc(), new tsv_ctype)); | |
iss >> std::skipws >> a >> b >> c; | |
std::cout << a << ":" << b << ":" << c << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment