I have a question, which very likely has been asked like this before, because I think what I want is something that a considerable amount of people would want. However I could n
The C++ library already offers some algorithms that implement most of the functionality you're trying to do on your own. I think it's better for you to adapt your template so that it would work seamlessly with the C++ library, instead.
I'm thinking specifically of std::generate()
.
So, you take what you're planning to do in your step #1, but replace step #2 with implementing an operator()
that returns the next value in the sequence.
Then, you can let std::generate
() take care of populating an actual sequence with your values.