The program below outputs 10. I expected it to first print 0 (the else branch of function f) and then to print 1. How come that the order is reversed?
#include <iostream>     
using namespace std;
int f(bool& b){
    if (b==true){
        return 1;
    } else {
        b=true;
        return 0;
    }
}
int main () {
    bool b=false;
    cout<<unitbuf<<f(b)<<unitbuf<<f(b);
  return 0;
}
The output
10
 
    