Boost logo

Boost :

From: Kevlin Henney (kevlin_at_[hidden])
Date: 2001-07-20 10:27:14


> From: "Fernando Cacciola" <fcacciola_at_[hidden]>
[...]
>> The original, pre-Boost version of any was written so that it could be
>> implemented using reference counting and copy-on-write. This is why the
>> original version had no non-const access to the contained member -- this
>> was added as a result of Boost reviewing.
>>
>> I presume you are proposing a class that is intended to be transparently
>> reference counting, ie using copy on write?
>No, not copy-on-write.
>I propose a variant type that is not a (deep) lvalue, so no copy on write is
>necessary. That's why I compared it to a *read only* string.
>You can *replace* the value but not *modifiy* it.

Good, in which case that avoids many of those infamous COW problems. In
effect you are proposing a const_any, with which I have much more
sympathy -- see http://www.cuj.com/experts/1905/henney.htm and
http://www.cuj.com/experts/1909/henney.htm.

>>If so, the implementation
>> you provided needs to perform a copy on the non-const any_cast. If not,
>> then I would suggest it should be to avoid mixing unrelated semantics
>> and ideas ;-)
>
>Of course this changes the semantic in that you don't have non-const access
>(which I forgot to modify on the sample code).

OK, it was this oversight that threw me.

Kevlin
____________________________________________________________

  Kevlin Henney phone: +44 117 942 2990
  mailto:kevlin_at_[hidden] mobile: +44 7801 073 508
  http://www.curbralan.com fax: +44 870 052 2289
  Curbralan: Consultancy + Training + Development + Review
____________________________________________________________


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk