Skip to content

Instantly share code, notes, and snippets.

@rahulbhadani
Created May 23, 2022 01:33
Show Gist options
  • Save rahulbhadani/ac89733855dacfddb249fc90b189019f to your computer and use it in GitHub Desktop.
Save rahulbhadani/ac89733855dacfddb249fc90b189019f to your computer and use it in GitHub Desktop.
Return Value Optimization
#include <string>
#include <functional>
#include <iostream>
#include <optional>
class Test {
public:
Test()
{
std::cout<<"Default Constructor\n";
}
Test(const Test&)
{
std::cout << "A copy constructor was called\n";
}
};
Test func()
{
return Test();
}
int main() {
std::cout << "Hello World!\n";
Test obj = func();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment