Is the C++ && constructor downside temporary?
https://news.ycombinator.com/item?id=27697382After watching https://www.youtube.com/watch?v=3LsRYnRDSRA&ab_channel=C%E1%90%A9%E1%90%A9WeeklyWithJasonTurner
I looked through my own library and realized I had been adding && constructors to generic templates without considering performance impact. I even had a linter rule to encourage me to do it.
Trying it out I found dozens of class template combinations that had a huge performance penalty. I also unfortunately found a few rare cases where the && constructor added a gigantic advantage. The differences are reduced with optimization, but its unclear if this penalty will ever go away entirely. The compiler is default choosing the && in cases when the alternatives e.g. copy would let the compiler optimize away far more. Profiling let me remove the worst offenders, but required me to add specialized constructors in a few cases. But for stuff like small size optimized vector (data smaller than a pointer), it must be runtime determined which should be used, which seems impossible to solve.
Is this problem temporary while the heroic and long suffering compiler programmers fix it, or did the damned committee make another well intended mistake?