How to prevent a temporary on the left hand side of the assignment operator
问题 If I define operator+ for a type, in the usual fashion struct S {}; S operator+(S const &, S const &) { return {}; } users of S can write code like S s{}; s + s = S{}; // huh From what I can tell, operator+ returns a temporary object of type S , which is then assigned to. The object then dies at the end of the statement, because there's no name for it, and so the statement is effectively a no-op. I don't see any use for code like that, so I would like to make that a compile error. Is there a