I guess you can blame me for this.
I've found that throwing an exception is something that is not small in code size. And so I like to outline functions that throw into sources when possible.
basic_ios::clear()
must sometimes throw an exception, and is also a template class. If I correctly recall, this annoyed me, as the rdstate
clearly does not depend upon the basic_ios
template parameters: CharT, Traits
. So I implemented rdstate
down in the base class (ios_base
), so that any associated non-inlined code could be shared by all instantiations of basic_ios
.
As sty correctly pointed out, ios_base::clear()
is implemented in src/ios.cpp. It is declared protected
in ios_base
, and then basic_ios::clear()
is just an inline forwarding to this common implementation.
In a nutshell: The "why" is a code size optimization.