Namespaces
Variants
Views
Actions

Talk:cpp/io/basic ios/clear

From cppreference.com
< Talk:cpp‎ | io

"Run" stopped with error, because there is no input data. Probably it can be emulated by echo -e: http://coliru.stacked-crooked.com/a/a371edbd37cc7a63 Ruslo (talk) 03:03, 5 September 2013 (PDT)

I've added this to my todo list. --P12 14:26, 10 September 2013 (PDT)

The following paragraph is confusing "If rdbuf() is a null pointer (i.e. there is no associated stream buffer), then state | badbit is assigned. May throw an exception." --- can the `clear()` function throw if the `rdbuf()` is a null pointer? Is that an exclusive or? What may throw exactly? --Alexis Wilke 12:54, 19 April 2021 (PDT)

I'm pretty sure that the example is not guaranteed to work. You can only reliably putback the last character read because otherwise the implementation would have to allocate and maintain an arbitrarily sized input buffer. Nick H 194.74.130.171 00:15, 18 August 2021 (PDT)

cin is not buffered; this calls C's ungetc which will indeed fail on HPUX and AIX after 1 char and on Solaris after 4, but I don't think it's material to the example. I guess I'll add a comment. --Cubbi (talk) 06:26, 18 August 2021 (PDT)