I have been using return by reference to try to speed up my code and avoid multiple expensive copy operations.
I have an access member function that looks like this:
std::string const& access_element(int index) const;
If I have another member function that calls access_element(), do I need to also return that by reference?
For instance.
float const& access_element2(int index) const {
return atof(access_element(index));
}
versus
float access_element2(int index) {
return atof(access_element(index));
}