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类),影响是全局性的!
  • 相关阅读:
    正则表达式
    jquery获取(设置)节点的属性与属性值
    Easy UI
    javascript中数组常用的方法
    DOM节点
    Echarts的基本用法
    CSS小结
    草稿1
    CSS基础
    wordbreak:breakall和wordwrap:breakword的区别
  • 原文地址:https://www.cnblogs.com/hustxujinkang/p/5105164.html
Copyright © 2011-2022 走看看