I had a similar idea for a new smart pointer that would aim to obsolete the
shared_ptr-to-const idiom. The problem I found with that idiom is that it
only guarantees that you can't change it. There's no promise that somebody
else doesn't have a non-const ref to the data and so it could in the worst
case completely change from under your feet (even if you know it won't get
destroyed).
This smart pointer would provide non-const access to it if, and only if,
you are currently the only person holding the object (ie,
shared_ptr::unique is true). This allows you to build up data and, once
complete, share it among the system as a const object that everybody knows
will not change because they know that as they have a hold of it nobody
else can change it.
I've spectacularly failed to find an appropriate name for this kind of
smart pointer. Other's at work have joked it should be called a
schrodinger_ptr...
On 20 April 2015 at 11:22, Andrey Semashev
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 internal reference counting.
Is this similar to Boost.Flyweight?
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost