In Nicola Gigante's lecture in 2015, he mentions (at the beginning) that there are no pure virtual functions in the Standard Library (or he's not aware of any). I believe that Alex Stepanov was against this language feature but since the initial STL design, have any pure virtuals creeped into the Standard library?
FWIW (and correct me if I'm wrong) the deleters in unique pointers ultimately use virtual dispatching in most implementations but these are not pure virtuals.
STL
(iterators, algorithms and containers) part? – Thithiaunique_ptr
are very non-virtual, so unsafe if you cast up to non-polymorphic base class.shared_ptr
on the other hand, keeps a type-erased deleter function with the original pointer, so is safe that way. – LightingSTL
. I suspect then that the point is that, inC++
generic programming as implemented in theSTL
is completely orthogonal to what might be considered typical methods in Object Oriented Programming. – Thithiastd::string
,std::complex
, exceptions. Nowstd::string
andstd::complex
are generally too time-critical to use virtual functions, nor is there a need to - polymorphism simply isn't needed for straightforward values. But <iostream> and exceptions do use virtual functions. – Boguszfinal
) that make many functions virtual in fundamental concrete classes (like containers) simply wouldn't be able to specify what it means, abstractly, to override these functions, and what the overrider would be allowed to do. – Tune