C++ Logo

sg16

Advanced search

Re: Why stdout is the default in std::print? (P2093)

From: Victor Zverovich <victor.zverovich_at_[hidden]>
Date: Wed, 2 Feb 2022 06:49:56 -0800
Some data confirming this claim can be obtained from codesearch.isocpp.org:

There are only 218 results for sync_with_stdio and even fewer for
sync_with_stdio(false). Moreover, some of these are from standard library
implementations themselves.

Query:
https://codesearch.isocpp.org/cgi-bin/cgi_ppsearch?q=sync_with_stdio&search=Search

To put it into perspective, there are ~200k main functions (
https://codesearch.isocpp.org/cgi-bin/cgi_ppsearch?q=int+main%28&search=Search)
many of which likely have some form of I/O.

A search in a very large internal codebase also confirmed these findings
with sync_with_stdio being virtually unused.

Cheers,
Victor



On Tue, Feb 1, 2022 at 10:35 AM Thiago Macieira via SG16 <
sg16_at_[hidden]> wrote:

> On Tuesday, 1 February 2022 10:18:49 PST Jens Maurer wrote:
> > Do you have any statistics or similar to back up your claim
> > "No one does that"?
> >
> > My personal experience is that it's a common recommendation to
> > disable the synchronization in a C++-only program that doesn't
> > use stdout/stderr at all.
>
> No, I don't. This is mostly a guess, based on:
> a) it's not the default, therefore few people will know about it or the
> recommendation (I'd never seen it myself, though it is logical)
> b) most programs aren't C++-only
>
> Real world gets in the way and we must interact with C libraries. I expect
> most libraries don't do output to stdout (libraries ought to be silent,
> except
> for libraries meant for output), but it does happen because in the real
> world,
> libraries often do unclean things.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DPG Cloud Engineering
>
>
>
> --
> SG16 mailing list
> SG16_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg16
>

Received on 2022-02-02 14:50:08