4 ms·
> requires you to have move operators for any classes you make Actually, in the specific case of std::list<T>, T can be both unmovable and uncopyable. Instead
by agwa 14y ago
> requires you to have move operators for any classes you make
Actually, in the specific case of std::list<T>, T can be both unmovable and uncopyable. Instead of using push_back() and insert() to insert elements, you use emplace_back(), and emplace() to construct the elements in place.
Also, the compiler is pretty good about auto-generating move constructors when all the members of a class are safely movable, so classes you write will probably be movable without you needing to do anything.
- beagle3 14y agoemplace_* is C++11 - which is rather new, with support on many platforms still lacking. They started ZeroMQ in 2007 (or even earlier? can't quickly find a reference). So, yes - some of the problems that they faced in ZeroMQ have been addressed years later (although the solution is not yet widely available). I believe this is a point FOR his conclusion that he should have used C, rather than a rebuttal.
- agwa 14y agoYeah, they're C++11-only. I probably should have mentioned that in my comment, but I didn't because the parent comment was specifically about C++11. I can completely understand why C++11 is not a usable solution for many people at this point.
- IsTom 14y agoAlso push_back() and insert() are actually emplace_back() and emplace() when used on rvalues.