You will definitely get further by checking the streambuffer identity
if (s.rdbuf() == std::cout.rdbuf())
This is because it is trivially simple to cross-assign / alias streams to buffers, see http://www.cplusplus.com/reference/iostream/ios/rdbuf/ and the Josuttis book