Out of curiosity!
What can you do with the returning iterator of std::generate_n?
Return value :
Iterator one past the last element assigned if
count > 0, first otherwise.
std::vector<int> v{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto iterator = std::generate_n(std::back_inserter(v), 10, [&]() {return j++;});
std::cout << "type: " << typeid(iterator).name() << '\n';
/*
for (iterator = v.begin(); iterator< v.end(); iterator++){
std::cout << *iterator << " " << endl;
}
*/
for(auto a : v)
std::cout << a << " ";
std::cout << std::endl;
Output:
type: St20back_insert_iteratorISt6vectorIiSaIiEEE
1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9
iterator shows a few member functions, but they are mostly operators.