|
|
|
|
|
by amluto
1861 days ago
|
|
> But nobody does that. Chances are someone on the team takes a shit about unnecessary memory copies It’s not just performance. In any moderately complicated C++ program, you will want a function to mutate its argument, and this falls apart. Sure, you can write in a pure functional style with immutable data structures, but I wish you luck implementing an immutable data structure with asymptotically reasonable performance without using pointers of some sort. |
|
In my experience a combination of pass-by-value with move semantics provides good code readability and almost optimal performance in most cases, so that's my default. Unless a profiler disagrees in specific cases, of course.