mardi 30 novembre 2021

Does always int i{0} be faster then int i = 0?

int i{0}; //(1)
int i = 0; //(2)

Do I have correct understanding that in first case (1) the variable i will be created already with 1 as it's value, and in (2) it will be created without a value and then assigned a value 1, so (1) will always faster then (2)?

But seems like most(all?) modern compilers will still optimize (2) to be same as (1) under the hood?

Aucun commentaire:

Enregistrer un commentaire