Boost logo

Boost :

Subject: Re: [boost] [ValueRef]
From: THOMAS JORDAN (tomjordan766_at_[hidden])
Date: 2015-04-20 10:54:03

> Message: 11
> Date: Mon, 20 Apr 2015 13:22:35 +0300
> From: Andrey Semashev <andrey.semashev_at_[hidden]>
> To: boost_at_[hidden]
> Subject: Re: [boost] [ValueRef] Interest in a new library for immutable
values with internal sharing?
> Message-ID: <1988978.ROPBOsQPor_at_lastique-pc>
> Content-Type: text/plain; charset="us-ascii"

> On Monday 20 April 2015 11:04:22 THOMAS JORDAN wrote:
> > Hi,
> > I'd like to gauge whether there might be any interest in a new Boost
> > library comprising a generic, non-intrusive, wrapper class for creating
> > immutable/const values with sharing of the underlying object via
> > reference counting.

> Is this similar to Boost.Flyweight?

It is similar in that both provide a 'smart' handle which can be used
pretty much as a drop in for the wrapped type.

However, Boost.Flyweight requires the wrapped type to be hashable. Also,
there is a level of indirection with Flyweight which can mean that
unnecessary temps may need to be created to do the initial lookup (and
addition) to the Flyweight store, unless you use the Flyweight key-map
interface. ValueRef does not use 'flyweighting.' That is, if there are two
ValueRefs created independently with the same value, e.g.,

ValueRef<std::vector<int> > v1(10,10), v2(10,10);

there will be two separate wrapped vector<int> objects - it is only when
copying/assigning that sharing takes place. It is simpler than Flyweight
and is essentially intended to be a more value-orientated option to
shared-ptr-to-const. Another (less significant) difference is that ValueRef
currently has no dependency on MPL, which I believe Flyweight does, though
that could well change if needed.

Boost list run by bdawes at, gregod at, cpdaniel at, john at