I believe the variants described could be implemented in C++ via virtual functions (overriding operations for specific types), inheritance-style mixins or the Visitor pattern (both used to add operations to an existing type, the latter being more dynamic than the former).