James Kanze
10/16/2008 9:52:00 AM
On Oct 15, 6:28 pm, joe <joeyc...@mail.com> wrote:
> I thought there was a way to do this in less lines (1 line?):
> std::vector<boost::shared_ptr<T> > m_vec;
> for (int i =0; i<totalSize; ++i)
> {
> m_vec.push_back(new T);
> }
> but my brain isn't letting me remember how right now. Anyone
> out there want to help?
How about std::fill_n with a back inserter and a
boost::function_output_iterator. For that matter, I'm pretty
sure that I saw an iterator adapter somewhere which stopped
after a maximum of n times; use that with the
function_output_iterator, and you should be able to use the two
iterator form of the constructor directly.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34