mercredi 29 mars 2017

std::stringstream; move assignment does not leave source in invalid state

According to the documentation, the move assignment operator should leave a source string stream in an invalid state:

Moves the string stream. The source stream becomes of invalid state after the operation.

(From: http://ift.tt/15xAp8C)

Given that, I would expect the following to output 0, but instead it outputs 1, using GCC 6.3.1.

#include <iostream>
#include <sstream>

int main()
{
    std::stringstream source;
    std::stringstream target;
    target = std::move(source);
    std::cout << bool(source);
    return 0;
}

I assume the documentation should read that the state is undefined instead of invalid, which seems a bit too strong in the context of streams. Can anyone confirm?

Aucun commentaire:

Enregistrer un commentaire