5

The page for std::basic_filebuf::sync() says that

sync() or its equivalent is implicitly called by ... seekoff(), and seekpos() ...

But I cannot seem to find any mention of this in the language spec, neither here or here.

My read of the filebuf portion of the spec for both seekoff() and seekpos() is that it isn't even clear that they effectively accomplish what sync() does (among the other things they're to do), let alone call it or its equivalent.

Is this phrasing on cppreference a misleading piece of information?

Geezer
  • 5,600
  • 18
  • 31
  • 2
    It's correct afaict.. `close` calls `overflow(traits​::​​eof())` to flush characters.. this is also what `sync` does as well.. – Brandon Aug 19 '18 at 13:33
  • @Brandon Thank you and sorry for including `close()` in the quote. That was my bad. I meant to ask about the *seek* methods. The question is now fixed. My apologies. – Geezer Aug 19 '18 at 13:39
  • Quoting from the link you gave, both `seekoff` and `seekpos` are specified to "update the output sequence and write any unshift sequence" . That's what the page refers to. – Cubbi Aug 27 '18 at 16:05
  • @Cubbi I fully agree, but `file_buf` is also an input streambuf, and by cppreference.com itself what `sync()` does on the input stream is implementation defined. And the standard for `seekpos` for example states otherwise -- i.e. that the input stream is being synced, not for the implementation to decide. – Geezer Aug 27 '18 at 16:16
  • @Chubbi as in, excuse the pun, something seemed not enough synced here to me, in this whole thing. That's the reason for the question – Geezer Aug 27 '18 at 16:17

0 Answers0