3 ms·
>Is returning references frequently done in C++? It is rather common to avoid copying returned objects. (perhaps it becomes less common with std::move ?) For
by benibela 6y ago
>Is returning references frequently done in C++?
It is rather common to avoid copying returned objects. (perhaps it becomes less common with std::move ?)
For example, the [] operator on the standard collections returns a reference, so the item can be modified
There Pascal has another clever idea. You can overload [] for reading and writing separately. Then x[k] := v becomes x.setItem(k, v)