Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Legibilidade com C++14 - get_numeric
struct numerical_appender {
numerical_appender(std::string &buf) : _buf(buf) { }
void operator()(const char c) {
if( c >= '0' && c <= '9' ) _buf.push_back(c);
}
private:
std::string &_buf;
};
void get_numeric(const std::string &input, std::string &output)
{
numerical_appender appender(output);
std::for_each(input.begin(), input.end(), appender);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment