#include <iostream>
#include <vector>
template <typename T>
std::vector<typename T::iterator> f(T t)
{
std::vector<typename T::iterator> v;
for (auto i = t.begin(); i != t.end(); ++i)
{
v.push_back(i);
}
return v;
}
template <typename T>
void print(const std::vector<T>& v)
{
for (auto i = v.begin(); i != v.end(); ++i)
{
std::cout << **i << ' ';
}
std::cout << std::endl;
}
int main()
{
std::vector<int> v{1, 2, 3};
print(f(v));
std::vector<std::vector<int>::iterator> itervec = f(v);
print(itervec);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgogCnRlbXBsYXRlIDx0eXBlbmFtZSBUPgpzdGQ6OnZlY3Rvcjx0eXBlbmFtZSBUOjppdGVyYXRvcj4gZihUIHQpCnsKICAgICAgICBzdGQ6OnZlY3Rvcjx0eXBlbmFtZSBUOjppdGVyYXRvcj4gdjsKICAgICAgICBmb3IgKGF1dG8gaSA9IHQuYmVnaW4oKTsgaSAhPSB0LmVuZCgpOyArK2kpCiAgICAgICAgewogICAgICAgICAgICAgICAgdi5wdXNoX2JhY2soaSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiB2Owp9CiAKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+CnZvaWQgcHJpbnQoY29uc3Qgc3RkOjp2ZWN0b3I8VD4mIHYpCnsKICAgICAgICBmb3IgKGF1dG8gaSA9IHYuYmVnaW4oKTsgaSAhPSB2LmVuZCgpOyArK2kpCiAgICAgICAgewogICAgICAgICAgICAgICAgc3RkOjpjb3V0IDw8ICoqaSA8PCAnICc7CiAgICAgICAgfQogICAgICAgIHN0ZDo6Y291dCA8PCBzdGQ6OmVuZGw7Cn0KIAppbnQgbWFpbigpCnsKICAgICAgICBzdGQ6OnZlY3RvcjxpbnQ+IHZ7MSwgMiwgM307CiAgICAgICAgcHJpbnQoZih2KSk7CiAgICAgICAgc3RkOjp2ZWN0b3I8c3RkOjp2ZWN0b3I8aW50Pjo6aXRlcmF0b3I+IGl0ZXJ2ZWMgPSBmKHYpOwogICAgICAgIHByaW50KGl0ZXJ2ZWMpOwp9CiAgICAgICAg