Skip to content

Instantly share code, notes, and snippets.

@0xch4z
Created October 27, 2017 03:56
Show Gist options
  • Select an option

  • Save 0xch4z/9627be57124fead33e096a17a1f64bc4 to your computer and use it in GitHub Desktop.

Select an option

Save 0xch4z/9627be57124fead33e096a17a1f64bc4 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
template <class T>
void log_vector(const std::vector<T> &vec) {
std::cout << "[" << std::endl;
for (const T el: vec) {
std::cout << '\t' << el << ',' << std::endl;
}
std::cout << "]" << std::endl;
}
int main(const int argc, const char **argv) {
std::vector<int> foo = { 1, 2, 3 };
log_vector(foo);
/**
* =>
* "[
* 1,
* 2,
* 3,
* ]"
*/
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment