Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » std::thread and std::vector confusion?

This thread is locked; no one can reply to it. rss feed Print
 1   2 
std::thread and std::vector confusion?
Thomas Fjellstrom
Member #476
June 2000
avatar

without the move it'll make a copy of inst to put into the vector, then inst itself will be destroyed some time later. If inst is big/complicated that could be expensive.

Ok, makes sense. Mind you I typically use pointers for big complex objects. So it's kindof a moot point.

taronĀ  said:

I personally don't use auto&& outside of template or generic lambdas.

I tend to only use auto (forget about &&) when I want to avoid typing out a long string of line noise that they call container iterator types. In that case you don't even want to make it a reference.

Now I have used T&& a fair bit in templates. or "Args&&... args" but thinking about it, that's probably best to trim down to "Args&... args" or drop the reference all together possibly. I'll have to test it. If the compiler isn't collapsing && down to & there, it'll case moves in places it won't be wanted in that code, sooo bad idea :o

append: Basically I stole some code from here and modified it a bit.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

 1   2 


Go to: