Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For long applications you get into he realm of tool chain bugs with C++. C compilers are more reliable.

If you write C-style C++, which parts of libstdc++ can you safely use without exceptions?



> which parts of libstdc++ can you safely use without exceptions?

Almost all of it, as long as you're happy to abort on memory allocation failure - which, according to the article, libvirt is now willing to do.

In fact for me, that's one of the main questions to ask when deciding between C and C++ for a project. Is it OK to abort on allocation failure? If so, use C++ (without using exceptions). If not, use C.


Google writes a lot of C++ code, disables exceptions entirely, and it does not shy away from STL at all.


Then they don't care about applications being terminated in case of std::bad_alloc and similar.

The crucial applications they use are written by others (like the Linux kernel).

Also, having seen the output of several Googlers, I think their code quality is overrated.


> Then they don't care about applications being terminated in case of std::bad_alloc and similar.

No, they don't: https://youtu.be/NOCElcMcFik?t=2304


   auto ptr = new (std::nothrow) ......
   if (ptr != nullptr) {
       //........
   }

Regarding STL, allocators with similar behavior can be provided.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: