How does the following code works to clear only the failbit in the cin stream?
cin.clear(cin.rdstate() & ~cin.failbit);
I am highly confused, as I was under the impression that cin.rdstate() returns an object of type iostate. This is then somehow compared with a single bit (cin.failbit) to clear only said bit. How exactly do the & and ~ work to achieve this?