A Look into Return Value Optimization of C++

I am learning C++ and ran into a "bizarre" issue, which was because Return Value Optimization (RVO) took place. In the spirit of learning C++, let's take a look into what's happening here. This is the code we will be looking at. struct Foo { Foo() { cout <<…