INTRO
Ref qualifiers : A way to dissambiguate the rl-valuness of the implied object. As a quick example, take the following class
class example { int member; public: // ... int& value() &; // ^ int&& value() &&; // ^^ int const& value() const&; // ^ };
The use of this C++11 feature (syntax marked with
^
), allows us to control the version ofvalue()
that will be called with- l-values
- temporaries
- const l-values
Practically the ref qualification applies to the classe's
*this
Defaulted / Deleted functions : Specify a special member function as having the compiler generated (default) definition or inaccessible (delete). As an example take
struct type { type(const type&) = delete; type& operator=(const type&) = delete; };
The above struct, achieves being non copyable with extremely clear semantics
QUESTIONs
- Is it possible / valid to combine these features ?
- Which are the cases where it's explicitly forbidden or bad style ?
- Is there any use case / pattern for such a combination ? (Eg creating conditional interfaces based rl-valueness quick and easy)