I have a function that looks like this:
// Fetch 1 MB of data void GetData(std::vector<char> & outData);
1MB is exaggerated, but I just want to indicate that it is preferable to avoid unnecessary copies.
If I add this overload:
std::vector<char> GetData() { std::vector<char> result; GetData(result); return result; }
Then, how likely is RVO?
With the most reasonably recent compilers (e.g. VS 2005 or later, gcc 3.4 or later), this is essentially certain. I only say "majority" because I have not tested every existing compiler. Each new compiler that I looked at probably the last 5 years included it.
RVO, , , , . , , NRVO. NRVO , . . MS-, , VS2005.
, : , .
, , ? , , , , , .
, RVO?
, .
, , .
. - , , .
, :
std::vector<char> GetData() { // : return result; } vector<char> x = GetData();
result " ", " " x. NRVO , . ctor , , ctor , .
result
x
Source: https://habr.com/ru/post/1759966/More articles:how to attach a list of tuples and dictate in a dict? - pythonPHP Print puts false characters on a web page when printing starts (ï "¿) - phpSQL to insert data into multiple tables with one POST in Razor WebMatrix syntax - sqlWhat exactly does ERROR_INVALID_ORDINAL mean? - dllhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1759965/how-do-i-get-access-to-the-querystring-in-windows-phone-7-from-a-user-control&usg=ALkJrhgTgdFXj7GYHsPDBdl-g_fHjYiZUQAndroid Launch the program of choice with the corresponding list of applications - androidProgrammatically switch between WiFi networks in .NET CF? - c #Не удается получить доступ к настройкам, созданным функцией PreferenceActivity - androidZip code discards leading zero when displayed on excel. Export to Excel to convert XML to XSLT - xmlIs it possible that the winform application loads its DLL from a path other than the root? - c #All Articles