Because setColor is implemented simply by inserting an int into the stream, the output will be affected by hex or oct or potentially other stream manipulators such as setw. Should the stream manipulator state be stored with ios.copyfmt and loaded after the escapes have been printed?