#include <iostream>
#include <vector>
#include <list>
#include <iterator>
#include <algorithm>
template<typename It>
void output_op(It it){
std::copy(it,it + 5,std::ostream_iterator<int>(std::cout));
}
template<typename It>
void output_adv(It it){
//auto end = std::next(it,5)も可
auto end = it;
std::advance(end,5);
std::copy(it,end,std::ostream_iterator<int>(std::cout));
}
int main() {
std::vector<int> v = {1,2,3,4,5,6,7,8,9,10};
std::list<int> l = {1,2,3,4,5,6,7,8,9,10};
output_op(v.begin());
//output_op(l.begin()); //Compile Error
output_adv(v.begin());
output_adv(l.begin());
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8bGlzdD4KI2luY2x1ZGUgPGl0ZXJhdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKdGVtcGxhdGU8dHlwZW5hbWUgSXQ+CnZvaWQgb3V0cHV0X29wKEl0IGl0KXsKCXN0ZDo6Y29weShpdCxpdCArIDUsc3RkOjpvc3RyZWFtX2l0ZXJhdG9yPGludD4oc3RkOjpjb3V0KSk7Cn0KdGVtcGxhdGU8dHlwZW5hbWUgSXQ+CnZvaWQgb3V0cHV0X2FkdihJdCBpdCl7CgkvL2F1dG8gZW5kID0gc3RkOjpuZXh0KGl0LDUp44KC5Y+vCglhdXRvIGVuZCA9IGl0OwoJc3RkOjphZHZhbmNlKGVuZCw1KTsKCQoJc3RkOjpjb3B5KGl0LGVuZCxzdGQ6Om9zdHJlYW1faXRlcmF0b3I8aW50PihzdGQ6OmNvdXQpKTsKfQoKaW50IG1haW4oKSB7CglzdGQ6OnZlY3RvcjxpbnQ+IHYgPSB7MSwyLDMsNCw1LDYsNyw4LDksMTB9OwoJc3RkOjpsaXN0PGludD4gbCA9IHsxLDIsMyw0LDUsNiw3LDgsOSwxMH07CgkKCW91dHB1dF9vcCh2LmJlZ2luKCkpOwoJLy9vdXRwdXRfb3AobC5iZWdpbigpKTsgLy9Db21waWxlIEVycm9yCgkKCW91dHB1dF9hZHYodi5iZWdpbigpKTsKCW91dHB1dF9hZHYobC5iZWdpbigpKTsKCQoJcmV0dXJuIDA7Cn0=