
Hi again, On Thu, Jun 14, 2012 at 2:45 AM, Dave Abrahams <dave@boostpro.com> [...]
Moreover, when using polymorphic value types implemented this way, you are still paying for one dynamic allocation and one deletion per copy of the object (this may be implementation–specific). Since those objects are supposed to be copied frequently,
Says who?
Well, if you go all that way to have polymorphism on value types and you take references to them, I fail to see why you did the effort in the first place. You actually said:
and => reference semantics (- hard to reason about)
I am probably missing the point, but I am not sure where.
Of course. And I don't want to avoid shared state completely. I want to avoid sharing state all over the place "by default." By the way, this affects single-threaded code too. If you haven't heard of "defensive copying" in the Java world, look it up.
I'll be doing that, many thanks for the advice. Julien