AJD
Here's some of the generated assembly:
int main() { 00401800 sub esp,18h vector2< float[3] > v1 = { 0, 1, 2 }; 00401803 xorps xmm0,xmm0 vector2< float[3] > v2 = { 3, 4, 5 }; vector2< float[3] > v3 = { 6, 7, 8 };
// Add two vectors lazily and get the 2nd element. #if 1 // this sticks temporary junk all over the stack, even with 2 terms std::cout << (v1 + v2)[0]; 00401806 fld dword ptr [__real <at> 40400000 (402128h)] 0040180C movss dword ptr [esp],xmm0 00401811 movss xmm0,dword ptr [__real <at> 3f800000 (402124h)] 00401819 movss dword ptr [esp+4],xmm0 0040181F movss xmm0,dword ptr [__real <at> 40000000 (402120h)] 00401827 movss dword ptr [esp+8],xmm0 0040182D movss xmm0,dword ptr [__real <at> 40400000 (402128h)] 00401835 movss dword ptr [esp+0Ch],xmm0 0040183B movss xmm0,dword ptr [__real <at> 40800000 (40211Ch)] 00401843 push ecx 00401844 mov ecx,dword ptr [__imp_std::cout (402044h)] 0040184A fstp dword ptr [esp] 0040184D movss dword ptr [esp+14h],xmm0 00401853 movss xmm0,dword ptr [__real <at> 40a00000 (402118h)] 0040185B movss dword ptr [esp+18h],xmm0 00401861 call dword ptr [__imp_std::basic_ostream
::operator<< (402040h)] std::cin.get(); 00401867 mov ecx,dword ptr [__imp_std::cin (40203Ch)] 0040186D call dword ptr [__imp_std::basic_istream
::get (402038h)] return 0; 00401873 xor eax,eax } 00401875 add esp,18h 00401878 ret
Just to be clear, the following is the expected assembly:
00401800 fld dword ptr [__real@41100000 (402118h)]
00401806 push ecx
00401807 mov ecx,dword ptr [__imp_std::cout (402044h)]
0040180D fstp dword ptr [esp]
00401810 call dword ptr
[__imp_std::basic_ostream