The following surely works but is very tedious:
T(const T&) = delete;
T(T&&) = delete;
T& operator=(const T&) = delete;
T& operator=(T&&) = delete;
I'm trying to discover the most concise way. Will the following work?
T& operator=(T) = delete;
Update
Note that I choose T& operator=(T)
instead of T& operator=(const T&)
or T& operator=(T&&)
, because it can serve both purposes.
It's enough to delete the copy operations, then the move operations will get removed automatically.
But if you're asking for "concise", according to this chart (by Howard Hinnant):
The most concise way is to =delete
move assignment operator (or move constructor, but it can cause problems mentioned in comments).
Though, as I said above, I wouldn't use this in practice, and would instead delete the copy constructor and copy assignment.