Polymorphic types

“The requirements of a polymorphic type, by definition, come from where you use the type, not from the type itself.” (S. Parent) "When I use inheritance, I build the use of my object into my object. On the contrary, what I want to do is separate the use of my…

Polymorphism: steady mode vs. initialization mode

You can find this kind of paragraph (about the advantages of runtime polymorphism, ed.) in any book teaching object-oriented techniques. The reason it is repeated here is to contrast the nice state of affairs in "steady mode" with the unpleasant "initialization mode" situation in which you must create objects in…

Remastered std::enable_if

While we wait for Concept Lite to find its way into the standard, here's a nice way of using SFINAE.…

Algorithms and value semantics

A nice consideration on value semantics and STL/boost algorithms: In generic implementations of algorithms it is preferred to use value semantics: copying an object causes two identical objects to exist which are independent. This is crucial property when it is necessary to duplicate objects. Dynamic polymorphism doesn't immediately work…