c++ - Is it possible to override std::endl? -


this question has answer here:

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

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -