On Wednesday, October 29, 2025, Arthur O'Dwyer wrote:


(Type 1)  Cannot be relocated
(Type 2)  Can be relocated by a simple memcpy
(Type 3)  Can be relocated by an algorithm built into the compiler
(Type 4)  Can be relocated by a custom-implemented relocator algorithm provided by the author of the class



There's a very clear physical delineation between Type 1, Type 2, and "all the rest."  The line between Type 3 and Type 4 is not physical but linguistic, and arbitrary.



Key difference between a Type 3 algorithm and a Type 4 algorithm:

Type 4 algorithm can be written in fully-portable C++ code with well-defined behaviour across all conforming implementations. An example would be the relocator for libstdc++'s std::string on Linux. (Or for any movable class: the combination of move + destroy).

Type 3 algorithm __must__ be written in platform-specific code targeting a particular operating system, a particular CPU instruction set, or a particular software or hardware or firmware configuration.

Type 3 will typically be written in very simple C code or assembler, whereas Type 4 will be full-blown C++ code.

And more on a human note . . . you can have a very proficient C++ programmer who isn't really sure what a vtable is, and therefore doesn't even know what the Type 3 algorithm is doing, whereas any decent  C++ programmer will understand the Type 4 algorithm.

I'm sure there are C++ programmers out there who have full understanding of how virtual methods work, without really knowing much about how vtables work.