Блог пользователя -is-this-fft-

Автор -is-this-fft-, история, 4 месяца назад, По-английски

Consider this code:

#include <iostream>

using namespace std;

int main () {
  ios::sync_with_stdio(false);
  ios::sync_with_stdio(true);
}

In GCC, are the C++ streams like std::cout etc then synchronized with the corresponding C methods like printf?

Answer
  • Проголосовать: нравится
  • +203
  • Проголосовать: не нравится

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

Is this behavior the same across all compiler?
or just unique to GCC?
is it specified on the C++ standard?

Why am I not checking it myself instead of asking questions? Cause I don't know where to check.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

So it feels like more of a "config" than "function"

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

I wonder why the C++ committee didn't do something like ios::desync_from_stdio() (without arguments), because the bool argument is really not needed.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится +8 Проголосовать: не нравится

    Because it doesn't really matter. You either allow resync to be implemented as part of existing interface but don't force it, or you allow resync to be implemented as an extra function within a namespace (a standard library implementation is allowed to add stuff, just users aren't) but don't force it. As software design decisions go, this one isn't worth focusing on.