Boost logo

Boost :

From: Andy Glew (glew_at_[hidden])
Date: 2000-01-07 15:46:27


> No matter how wonderful such a method is and how useful
> it could be to implement, say, synchronized containers,
> my point was that using mutexes to synchronize shared_ptr
> reference counting is a huge overkill - instead of changing
> one instruction from simple increment to atomic one,
> you would _add_ new data members and mutex syncronization
> which is much more that atomic increment. Also, shared_ptr
> does not neeed to be fully synchronized, only assignment does.

So can we not specialize, then:

template<class T>
class mutex< shared_ptr<T> > : public shared_ptr<T> {
public:
    ....
};

No, you're right... G++ fails this.

You can specialize on a case by case basis:

template<>
class mutex< shared_ptr<int> > : public shared_ptr<int> {
public:
    type mutex< shared_ptr<int> > m;
    m& operator=( const m& that ) {
        atomic_increment( ... )
        ...
    }
};

but that leaves a lot to be desired.


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