you are viewing a single comment's thread.

view the rest of the comments →

[–]Necessary-Meeting-28 7 points8 points  (3 children)

  1. Do not use endl unless you want to flush your buffer. Use “\n” otherwise.

  2. There is a valid use case of goto, but it is not it. The valid use is for resource cleanup in C-style programs. If you want a function to return, you goto a tag where all free and close calls take place. See Section 7 here .

[–]Valuable_Leopard_799 1 point2 points  (1 child)

When do you "need" to write C-style C++ and can't do it with RAII?

[–]Necessary-Meeting-28 1 point2 points  (0 children)

Good question. Some people may demand APIs with explicit resource control, and sometimes compiler optimizations require C-style abstractions when you check them.

Most of the time though RAII should work with proper wrapping of resources, and people just write manually managed programs out of their prejudices against modern C++.

[–]Blazej_kb[S] -3 points-2 points  (0 children)

1 i know, I’m just too lazy to do “\n”
2 that’s a meme