4 ms·
Change class is simulated in C++ via the State Pattern and possibly others. Any pimpl variant can achieve an effective change class by allowing an object's inte
by kazinator 11y ago
Change class is simulated in C++ via the State Pattern and possibly others. Any pimpl variant can achieve an effective change class by allowing an object's internal representation to be mutated to a new representation.
I once made a list/binary search tree library called Austin, purely in C. This library lets you dynamically change the type of an object from one kind of binary search tree to another. For instance from Red-Black to AVL or Splay. Or to a sorted linked list. There is a "vtable" in there which gets swizzled to point to different operations. During the swizzling, there are special operations which handle the needed reorganizations of the tree.