c++ - Is it possible to override std::endl? -
this question has answer here:
- overload handling of std::endl? 6 answers
i creating wrapper class around std::ofstream. have override std::ofstream methods. now, need override std::endl method use wrapper class instead of basic_ostream.
is possible override std::endl method? can give me example?
first: never allowed overload functions in ::std namespace. in fact, only allowed specialize existing templates in ::std namespace , restrictions.
you can deal endl situation reading in c++11 27.7.3.8/1:
effects: calls os.put(os.widen(’\n’)), os.flush().
therefore, need override nothing, provide correct member functions deal sequence of put, widen , flush.
Comments
Post a Comment