Feeling the Named VBO?

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?

+3
source share
5 answers

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.

+7
source

RVO, , , , . , , NRVO. NRVO , . . MS-, , VS2005.

+3

, : , .

, , ? , , , , , .

+2

, RVO?

, .

, , .

. - , , .

0

, :

std::vector<char> GetData() 
{ 
//   :
    return result; 
}

vector<char> x = GetData();

result " ", " " x. NRVO , . ctor , , ctor , .

0
source

Source: https://habr.com/ru/post/1759966/


All Articles