In the following MVE, does the return value of the Get
function qualify for copy elision?
#include <map>
#include <string>
std::map<std::string, std::string> mVariables;
std::string Get(const std::string& variableName)
{
const auto variableIt = mVariables.find(variableName);
if(variableIt==std::end(mVariables)) {
throw std::runtime_error("Unknown variable requested.");
}
return variableIt->second;
}
int main()
{
mVariables["key"] = "value";
auto value = Get("key");
return 0;
}
Aucun commentaire:
Enregistrer un commentaire