Created
September 19, 2023 23:38
-
-
Save apivovarov/b192a8ec73a24925b5b0fa000f4e63be to your computer and use it in GitHub Desktop.
NRVO Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
std::vector<int> testNRVO(int value, size_t size, const std::vector<int> **localVec) | |
{ | |
std::vector<int> vec(size, value); | |
*localVec = &vec; | |
/* Do something here.. */ | |
return vec; | |
} | |
int main() | |
{ | |
const std::vector<int> *localVec = nullptr; | |
std::vector<int> vec = testNRVO(0, 10, &localVec); | |
if (&vec == localVec) | |
std::cout << "NRVO was applied" << std::endl; | |
else | |
std::cout << "NRVO was not applied" << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment