3 ms·
> Arguably the std::move stuff and the semantics around it have added uncomfortable complexity to the language Compared to using std::auto? Nah man. std::move
by dragontamer 10y ago
> Arguably the std::move stuff and the semantics around it have added uncomfortable complexity to the language
Compared to using std::auto?
Nah man. std::move is far easier to understand than trying to shove both concepts down operator=. std::unique is simply easier to use than std::auto by any real measurement.
- cmrdporcupine 10y agoMy perhaps naive uneducated opinion: they should have added syntactic sugar for it instead of making it look like a function. A new operator perhaps.
- dragontamer 10y ago> A new operator perhaps. That'd invalidate a lot of programs. Just like how the new _ operator in Java is killing a lot of code right now. Every symbol that can be used... has been used. "Move" is the meaning of the operator in any case. Its no less readable than say... Python's __lshift__ or __add__.
- sqeaky 10y agoWhat if a hypothetical new operator used only characters already not allowed in identifiers and composed of characters not allowed in contiguous operator sequences. Consider: :=, <-=, <|, $,
- cbsmith 10y agoAFAIK, _ isn't an operator in Java (http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.12 http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#...). The language does allow _ to be used as a separator in numeric literals. Is there a new operator in some upcoming version of the language specification?
- kevinnk 10y agoHow does adding an operator help? There are two main advantage of having move semantics in the language and at least one of them relies on the fact that moves are implicit; you can write code that will move objects if supported and copy/destroy if not (for example, when returning an object or using an intermediate value in an expression). Adding an operator erases that advantage. The other advantage is that you can force only move semantics which allows enforcing things like ownership. Adding an operator doesn't destroy this advantage, but it is a bit silly since you're just adding line noise for something that really should be implicit anyway. Unless you just literally don't like the spelling of "std::move" which seems pretty lame since it should be relatively rare anyway.