Re:Std: Print is headed for C++23. std:cout is now a code smell
by google234123 on Monday November 29, 2021 @10:22PM
(#29388561)
std::cout::write(myInt,": ",something," - ",otherthing," - ",etc,'\n');
Possible with preprocessor.
Re:Std: Print is headed for C++23. std:cout is now a code smell
by slavik81 on Tuesday November 30, 2021 @01:34AM
(#29389558)
I'm not sure how that could be done before variadic templates were introduced in C++11.
Re:Std: Print is headed for C++23. std:cout is now a code smell
by fbkr on Tuesday November 30, 2021 @01:48AM
(#29389629)
I doubt that's possible with the C++98 preprocessor.
Re:Std: Print is headed for C++23. std:cout is now a code smell
by kayamon on Wednesday December 01, 2021 @01:29AM
(#29401273)
> However, in C++98, how else would you handle when you have an arbitrary number of things to print in a type-safe way? e.g.
If I were the one designing the language, I'd have simply fixed printf to be type-safe. (e.g. via adding macro support a la Lisp)
However, in C++98, how else would you handle when you have an arbitrary number of things to print in a type-safe way? e.g.
printf is not type-safe, nor supports user defined types. I'd rather not write 8 lines of functions calls for the same thing either.I think it made some sense C++98, though it is an awful API in 2021.