why is std::cout convertible to void* if using g++?

前端 未结 3 1699
后悔当初
后悔当初 2021-01-02 00:22

Why can one cast a std::ostream to a void pointer? I am not aware of any such conversion operator in std::ostream. Code below

3条回答
  •  迷失自我
    2021-01-02 00:54

    I think it's to allow for if (std::cout) ... without allowing for implicit conversion to bool, or something like that.

提交回复
热议问题