mardi 14 juin 2016

Is there a c++ temporary rvalue for constants


Are temporaries generated in C++ when a literal constant / basic types is assigned to a variable? Does this differ between C++ specifications (c++98,c++11,c++14,c++17,etc)?

int a = 1; // 1 here is likely loaded in microcode level, right? But not guaranteed not to generate a temp value

int b = 1+2; // evaluated to 3 at compile time as const, also 3 might not exist in microcode. Likely temp value

auto c = 3; // creates an int based on 3. No temp value

int a{1}; //no temp value?

I am reading https://herbsutter.com/2013/05/13/gotw-2-solution-temporary-objects/.

Also, I assume I am completely wrong on all of this


Aucun commentaire:

Enregistrer un commentaire