11 karma · joined Jan 3, 2013 (13y ago) · 7 submissions
comment 13y ago · link · parent
That is to say if you have a constructor:
MyClass::MyClass(const std::string& s) : m_s(s) {}
That you call like: std::string s = "Some string";
MyClass c(s);
You're hamstringing the compiler into always copying that string instead of being able to use the new move semantics, because it can't mess with the guts of a const reference. Instead, do the previously unspeakable evil of passing by value and then moving, e.g. MyClass::MyClass(std::string s) : m_s(std::move(s)) {}
This lets the compiler know that if string has a move constructor, and is an rvalue, it can just move the guts into place instead of performing the copy, since the variable is 'sunk' into the new location. Huge wins all around.comment 13y ago · link · parent
He also doesn't seem to be making a weird logical leap the way you claim he is. He's not really using an analogy. He's saying callbacks are bad the same way goto is bad, in that they make the logical structure of a program's execution non-obvious, particularly over time and when being modified.
comment 13y ago · link · parent
comment 13y ago · link · parent
If I run a blog called "Murderer Watch: Keeping an Eye on Murderers and Things" and I post "Bob Jones is 34 and lives in Atlanta, GA," that can't be totally okay just because those are all factual statements, right?