Почему libstdc++ часто использует базовые классы для контейнеров STL [дубликат]C++

Программы на C++. Форум разработчиков
Гость
Почему libstdc++ часто использует базовые классы для контейнеров STL [дубликат]

Сообщение Гость »


I noticed that libstdc++ often uses a base class for the implementation of standard allocator-aware containers. Especially, some basic functionalities are implemented in a base class that is inherited by the correponding container class, like std::vector, std::deque, std::forward_list and std::list.

The comments in the header files do not offer an explanation for this design choice, and the comment in the stl_deque.h file just says that the technique makes exception safety easier.

Pedantically, how would the base class make exception safety easier?


Источник: https://stackoverflow.com/questions/781 ... containers

Вернуться в «C++»