Synchronizing iostream with stdio
Threads are synchronized by default, they guarantee to work as standard, you don't need to do anything. sync_with_stdio
is only intended to disable sync if you want.
From the article mentioned:
For predefined streams, it is safe to mix stdio and iostreams. For example, you can safely use stdin and cin in the same program; The C ++ Standard ensures that it will work as you naively expect it to.
The only downside is potential performance hit (I think why it might be disabled).
source to share
As TheSamFrom1984 says, default sync is not a problem. However, synchronization only makes sense when the same streams are used by both libraries. This usually happens when using cin / cout / cerr and stdin / stdout / stderr respectively. However, I can see several reasons why both should be used at the same time, aside from reusing legacy code.
When I first started using C ++ I found myself doing this because often I knew how to do something with stdio but didn't know how to do it with iostream, but the best approach is to figure out how do it one or the other, but not both.
source to share