#include <iostream>
#include <iterator>
#include <vector>
template <typename OutputIterator>
OutputIterator F1( OutputIterator out )
{
std::cout << "F1 was called\n";
/* Insert stuff via *out++ = ...; */
*out++ = 7;
return out;
}
int main()
{
std::vector<int> Concat;
// perhaps reserve some moderate amount of storage to avoid reallocation
F1( std::back_inserter(Concat) );
F1( std::back_inserter(Concat) );
for (auto i : Concat)
std::cout << i << ", ";
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDx2ZWN0b3I+Cgp0ZW1wbGF0ZSA8dHlwZW5hbWUgT3V0cHV0SXRlcmF0b3I+Ck91dHB1dEl0ZXJhdG9yIEYxKCBPdXRwdXRJdGVyYXRvciBvdXQgKQp7CiAgICBzdGQ6OmNvdXQgPDwgIkYxIHdhcyBjYWxsZWRcbiI7CiAgICAvKiBJbnNlcnQgc3R1ZmYgdmlhICpvdXQrKyA9IC4uLjsgKi8KICAgICpvdXQrKyA9IDc7CiAgICByZXR1cm4gb3V0Owp9CgppbnQgbWFpbigpCnsKICAgIHN0ZDo6dmVjdG9yPGludD4gQ29uY2F0OwogICAgLy8gcGVyaGFwcyByZXNlcnZlIHNvbWUgbW9kZXJhdGUgYW1vdW50IG9mIHN0b3JhZ2UgdG8gYXZvaWQgcmVhbGxvY2F0aW9uCgogICAgRjEoIHN0ZDo6YmFja19pbnNlcnRlcihDb25jYXQpICk7CiAgICBGMSggc3RkOjpiYWNrX2luc2VydGVyKENvbmNhdCkgKTsKICAgIAogICAgCiAgICBmb3IgKGF1dG8gaSA6IENvbmNhdCkKICAgICAgICBzdGQ6OmNvdXQgPDwgaSA8PCAiLCAiOwp9