In this chapter, we will learn some advanced C++ exception handling techniques. We assume here that you have a basic understanding of how to throw as well as catch a C++ exception. Instead of focusing on the basics of C++ exceptions, this chapter will teach you some of the more advanced techniques of C++ exception handling. This includes the proper use of the noexcept specifier and the noexcept operator so that you can properly mark your APIs as either possibly throwing an exception or explicitly not throwing a C++ exception, instead of calling std::terminate() when an error occurs that cannot be handled.
This chapter will also explain what the term Resource Acquisition is Initialization (RAII) is and how it complements C++ exception handling. We will also discuss why you should never throw a C++ exception from a class's destructor...