zoukankan      html  css  js  c++  java
  • sync_with_stdio

     /*  The synchronization referred to is @e only that between the standard
    * C facilities (e.g., stdout) and the standard C++ objects (e.g.,
    * cout). User-declared streams are unaffected. See
    * https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary
    */
    很多人对于同步的问题有误解
    其实同步只针对cin, cout, cerr, clog(加上宽字符版本)共八个有影响,gcc的实现中是特意为它们定义了stdio_stream_buf的,而
    且编译器开后门保证它们只初始化一次
    而我们自己定义流的话,istream. ostream, fstream, sstream都要有一个stream_buf丢进去,这时候,我们根本没法使用stdio_stream_buf
    能用到的就是file_buf和string_buf, file_buf底层使用的read write等 无缓冲的api,缓冲区是在stream_buf中自己管理的
    所以自定义的流调用sync_with_stdio是没有意义的:而且要注意sync_with_stdio是一个static成员函数(来自ios_base类),影响是全局性的!
  • 相关阅读:
    004.Jquery库的用法
    update 死锁问题
    Nginx负载均衡模式
    微信公众号开启服务器配置 JAVA
    mybatis plus + AOP 多数据源自动切换
    mybatis plus 快速上手
    mybits 笔记
    java 异步
    node 垃圾回收机制
    常用正则
  • 原文地址:https://www.cnblogs.com/hustxujinkang/p/5105164.html
Copyright © 2011-2022 走看看