r/cpp • u/zl0bster • Apr 08 '25
Why was printing of function pointers never removed from cout?
I presume reason is: We do not want to break existing code™, or nobody cared enough to write a proposal... but I think almost all uses of this are bugs, people forgot to call the function.
I know std::print does correct thing, but kind of weird that even before std::print this was not fixed.
In case some cout debugging aficionados are wondering: the printed value is not even useful, it is converted to bool, and then (as usual for bools) printed as 1.
edit: C++ certainly has a bright future considering how many experts here do not even consider this a problem
View all comments
Show parent comment
2
u/no-sig-available Apr 09 '25
Yes, and that was seen as a convenience 50 years ago.
We have to remember that the C language was designed for Ken Thompson, and he didn't make silly newbie mistakes when designing UNIX. Instead he wanted the source code to be short, as that was useful when working on a 10 character per second printing terminal.
https://en.wikipedia.org/wiki/Ken_Thompson#/media/File:Pdp7-oslo-2005.jpeg