VonTum@programming.devtoC++@programming.dev•The move constructor that you have to declare, even though you don't want anyone to actually call it - The Old New Thing
1·
1 year agoWell, it’s really interesting that this is a hack that works, but you’re really fighting the compiler here.
This is making me all the happier I switched to Rust 😂
True, though here the hack is incredibly unintuitive for the programmer. You have to declare the constructor, but then leave it unimplemented. Not to mention the compiler error that should catch this now only occurs at link time, and linking errors are even more cryptic to grok.
When they made RVO mandatory, they should’ve removed the constructor declaration requirement as well, instead of a half-ass solution like this.
As a final nail in the coffin, std::is_move_constructible<> suddenly returns true for this non-move-constructible type 😉