std::cout.put(65) writes "A"

So not compatible.

puts("65") expects a pointer and writes "65\n"

 

For print and println ostream-members have been created in addition to free std::print and std::println, and it would make sense for such an autodetecting function.

 

puts has string in its name and would be illogical to auto-detect other types. One can reason it would convert to string.

 

Would it be safe and continue to work with any current use?

 


 

-----Ursprüngliche Nachricht-----
Von: Ville Voutilainen via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: So 14.05.2023 15:39
Betreff: Re: [std-proposals] D2879R0 Proposal of Pythonesque std::print extensions LIVE LINK
An: Andrew Tomazos <andrewtomazos@gmail.com>;
CC: Ville Voutilainen <ville.voutilainen@gmail.com>; std-proposals@lists.isocpp.org;
On Sun, 14 May 2023 at 16:13, Andrew Tomazos <andrewtomazos@gmail.com> wrote:
>
> Sebastian Wittmeier  wrote:
>>
>> > std::put used
>
>
> Where is std::put used in the existing standard library?

Nowhere, but there's a
https://en.cppreference.com/w/cpp/io/basic_ostream/put which almost
matches the intent here, because
it's an unformatted output function.


> So I was thinking we could propose that:
>
>     std::put(1,2,3);
>
> is equivalent to:
>
>    std::println("{} {} {}", 1, 2, 3);
>
> and forget about all the other forms.

ostream::put doesn't put a newline, whereas this function would. I
don't find that a consistent API.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals