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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -