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

What is “rvalue reference for *this”?

First, “ref-qualifiers for *this” is a just a “marketing statement”. The type of *this never changes, see the bottom of this post. It’s way easier to understand it with this wording though. Next, the following code chooses the function to be called based on the ref-qualifier of the “implicit object parameter” of the function†: // … Read more