Boost logo

Boost :

From: Angus Leeming (angus.leeming_at_[hidden])
Date: 2004-01-08 13:39:13


David Abrahams wrote:
> Will your code work just as well if unique changed to:
>
> bool unique() const // nothrow
> {
> return weak_count() == 1;
> }

I believe so, yes, because I store shared_ptr copies of the cached
item:

        /** Get the cache item associated with file.
         * Returns an empty container if there is no such item.
         *
         * IMPORTANT: whatever uses an image must make a local
         * copy of this ItemPtr.
         * The boost::shared_ptr<>::use_count() function is
         * used to ascertain whether or not to remove the item
         * from the cache when remove(file) is called.
         *
         * You have been warned!
         */
        typedef boost::shared_ptr<CacheItem> ItemPtr;
        ItemPtr const item(std::string const & file) const;

The app in question does not use weak_ptr at all (anymore).

Regards,
Angus


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