When to use functors over lambdas

A lambda is a functor – just defined with a shorter syntax. The problem is that this syntax is limited. It doesn’t always allow you to solve a problem in the most efficient and flexible way – or at all. Until C++14, the operator() couldn’t even be a template. Furthermore, a lambda has exactly one … Read more

How to assert if a std::mutex is locked?

Strictly speaking, the question was about checking the lockedness of std::mutex directly. However, if encapsulating it in a new class is allowed, it’s very easy to do so: class mutex : public std::mutex { public: #ifndef NDEBUG void lock() { std::mutex::lock(); m_holder = std::this_thread::get_id(); } #endif // #ifndef NDEBUG #ifndef NDEBUG void unlock() { m_holder … Read more

When will C++0x be finished? [closed]

As Howard already said in the question, the final draft was completed on March 25, 2011. There will now be some months of editorial changes, voting and ISO red tape before it officially becomes a standard, but on the 25th, the standards committee themselves officially signed off on it. Sources: https://www.ibm.com/developerworks/mydeveloperworks/blogs/5894415f-be62-4bc0-81c5-3956e82276f3/entry/the_c_0x_standard_has_been_approved_to_ship23?lang=en http://herbsutter.com/2011/03/25/we-have-fdis-trip-report-march-2011-c-standards-meeting/ http://twitter.com/#!/sdt_intel/status/51328822066417665 and of … Read more

Move constructor on derived object

rval is not a Rvalue. It is an Lvalue inside the body of the move constructor. That’s why we have to explicitly invoke std::move. Refer this. The important note is Note above that the argument x is treated as an lvalue internal to the move functions, even though it is declared as an rvalue reference … Read more