The reason is that std::pairs can be converted to each other.
If the type doesn't match exactly:
1) It will be implicitly converted to the correct type.
2) Then you get a reference to first.
3) Then the temporary created in step 1 is destroyed
4) Then you stream first (which has just been destroyed)
 
Thank you, now I see.