Skip to content

Instantly share code, notes, and snippets.

@catupper
Created March 31, 2019 15:39
Show Gist options
  • Save catupper/772f2055b4ee0615ab2c993fedd55179 to your computer and use it in GitHub Desktop.
Save catupper/772f2055b4ee0615ab2c993fedd55179 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<vector>
using namespace std;
//1
#define view_vector1(vec) for(auto v:vec)cout << vec << " ";cout << endl;
//2
template<typename T>
ostream& operator<<(ostream& stream, vector<T>& vec){
for(T v:vec)stream << v << " ";
return stream;
}
int main(){
vector<int> hoge = {3, 1, 4, 1, 5, 9, 2};
view_vector1(hoge);
cout << hoge << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment