Why does multiple calls to xalloc result in delayed output?
        Posted  
        
            by 
                Me myself and I
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Me myself and I
        
        
        
        Published on 2013-06-28T15:56:03Z
        Indexed on 
            2013/06/28
            16:21 UTC
        
        
        Read the original article
        Hit count: 284
        
When I print the id of a stream in a single expression it prints it backwards. Normally this is what comes out:
std::stringstream ss;
std::cout << ss.xalloc() << '\n';
std::cout << ss.xalloc() << '\n';
std::cout << ss.xalloc();
Output is:
4
5
6
But when I do it in one expression it prints backwards, why?
std::stringstream ss;
std::cout << ss.xalloc() << '\n'
          << ss.xalloc() << '\n'
          << ss.xalloc();
Output:
6
5
4
I know the order of evaluation is unspecified but then why does the following always result in the correct order:
std::cout << 4 << 5 << 6;
Can someone explain why xalloc behaves differently? Thanks.
© Stack Overflow or respective owner