3 ms·
C++ is a value semantic language. Copies are implicit and references are explicit (expressed in the syntax). Many other languages are reference oriented, and re
by nly 6y ago
C++ is a value semantic language. Copies are implicit and references are explicit (expressed in the syntax). Many other languages are reference oriented, and references are implicit and copies are explicit. Both have pros and cons, and in both you sometimes want to cross the aisle.
When you consider that references in C++ need to be explicit you have the following solution:
https://gcc.godbolt.org/z/PGbc46cxK https://gcc.godbolt.org/z/PGbc46cxK