
on Thu Jun 07 2012, "Hite, Christopher" <Christopher.Hite-AT-partner.commerzbank.com> wrote:
Chris:
* people shouldn't use any to replace classic interfaces and virtual functions Dave Abrahams: Excuse me, but why not? Doing polymorphism this way eliminates all kinds of nastiness that we get with classic interfaces and virtual functions. Luke: Perhaps we should make sure the documentation clearly states what kinds of nastiness the library allows us to avoid and how it is intended to be used. It solves a lot of problems ....
So the nice thing about the any vs. classic virtual functions is it is nonintrusive.
Actually, that's only one of many nice things. See Sean Parent's 2nd talk from C++Now! Oh, the videos aren't posted yet. Well, the chain of implications, off the top of my head, goes like this: OOP => different sized objects being handled through the same interface => dynamic allocation (- complicated) => memory management (- hard) and => reference semantics (- hard to reason about) => shared state (- hard to reason about) => MT synchronization => deadlocks, races, and inefficiency In a nutshell, concept-based-runtime-polymorphism/type-erasure allows you to have runtime polymorphism while preserving value semantics. The value of that win is very commonly underestimated. -- Dave Abrahams BoostPro Computing http://www.boostpro.com