Why do C++ streams use char instead of unsigned char?

后端 未结 4 430
鱼传尺愫
鱼传尺愫 2020-12-02 14:13

I\'ve always wondered why the C++ Standard library has instantiated basic_[io]stream and all its variants using the char type instead of the unsigned char

4条回答
  •  鱼传尺愫
    2020-12-02 15:00

    I think this comment explains it well. To quote:

    signed char and unsigned char are arithmetic, integral types just like int and unsigned int. On the other hand, char is expressly intended to be the "I/O" type that represents some opaque, system-specific fundamental unit of data on your platform. I would use them in this spirit.

提交回复
热议问题