Skip to content

Instantly share code, notes, and snippets.

@thiagomg
Created May 5, 2015 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagomg/608c1e50eee63836de1d to your computer and use it in GitHub Desktop.
Save thiagomg/608c1e50eee63836de1d to your computer and use it in GitHub Desktop.
Do macro ao template
template<typename T, typename U>
void fill(T &t, U start, U end, U step) {
for(U i=start; i < end; i += step) {
t.push_back(i);
}
}
template<typename T>
auto accum(T &t) {
typename T::value_type ret{};
for(auto &item : t) {
ret += item;
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment