In C++, what categories (lvalue, rvalue, xvalue, etc.) can expressions that produce temporaries of class type fall into?

Every expression is one, and only one, of: lvalue xvalue prvalue The union of expressions that are lvalues and xvalues are known collectively as glvalues. The union of expressions that are xvalues and prvalues are known collectively as rvalues. Thus xvalue expressions are known both as glvalues and rvalues. The handy diagram found in Alf‘s … Read more

What’s a use case for overloading member functions on reference qualifiers?

In a class that provides reference-getters, ref-qualifier overloading can activate move semantics when extracting from an rvalue. E.g.: class some_class { huge_heavy_class hhc; public: huge_heavy_class& get() & { return hhc; } huge_heavy_class const& get() const& { return hhc; } huge_heavy_class&& get() && { return std::move(hhc); } }; some_class factory(); auto hhc = factory().get(); This does … Read more

Why user-defined move-constructor disables the implicit copy-constructor?

I’ve upvoted ildjarn’s answer because I found it both accurate and humorous. 🙂 I’m providing an alternate answer because I’m assuming because of the title of the question that the OP might want to know why the standard says so. background C++ has implicitly generated copy members because if it didn’t, it would’ve been still-born … Read more