Does pubsetbuf() ever return nullptr?

cplusplus_com wrote:
streambuf* pubsetbuf ( char* s, streamsize n );

In case of success, the member function should return a pointer to the object (this pointer), otherwise a null pointer.

http://cplusplus.com/reference/streambuf/streambuf/pubsetbuf/

This means I should check if it returns nullptr, right?
cppreference.com make no mention of the return value being null.

http://en.cppreference.com/w/cpp/io/basic_streambuf/pubsetbuf
Last edited on
C++11 §27.6.3.2.2
basic_streambuf<char_type,traits>* pubsetbuf(char_type* s, streamsize n);
Returns: setbuf(s, n).


C++11 §27.6.3.4.2
basic_streambuf* setbuf(char_type* s, streamsize n);
Effects: Influences stream buffering in a way that is defined separately for each class derived from basic_streambuf in this Clause (27.8.2.4, 27.9.1.5).
Default behavior: Does nothing. Returns this.


Note that it says Default behavior. I think that is because setbuf is a virtual function so derived classes can override it to return something else.
Topic archived. No new replies allowed.