samedi 31 janvier 2015

Are two calls to cout less efficient than one?

I have two questions:




  1. Is two calls to std::cout less efficient than one?




  2. If yes, does the compiler (usually) optimize it and generate equal assembly for the three cases shown below?




For example:



std::cout << "a" << "b";


or



std::cout << "ab";


or



std::cout << "a";
std::cout << "b";


I ask, because I think the last one is the most readable for a longer list of text to output.


Aucun commentaire:

Enregistrer un commentaire