c++ - Custom streambuffer in std::ofstream -
i know in std::ostream, can use custom streambuf through either stating in constructor:
std::ofstream temp; temp.open("file.txt", std::ios_base::in); std::ostream example(temp.rdbuf()); as setting afterwards (same first 2 lines before, change last line to:
std::ostream example; example.rdbuf(temp.rdbuf()); my question is: how can in std::ofstream? want able overwrite methods xsgetn , xsputn implemented in std::streambuf in own custom class , use in ofstream, but, short of writing own custom ofstream unsure of how so.
the concrete file stream classes have own rdbuf() method takes 0 arguments , hides other rdbuf() method inherited virtual base std::basic_ios. qualifying name lookup base class method should work:
std::ofstream ofs; ofs.basic_ios<char>::rdbuf(example.rdbuf());
Comments
Post a Comment