Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-05-18 03:46:55


From: "Eric D Crahen" <crahen_at_[hidden]>
[...]

> template <class T, class LockType>
> class GuardedObject : private NonCopyable {
>
> T* _object;
> LockType _lock;
>
> friend class Proxy;
> class Proxy : public Guard<T> {

Noncopyable, since a scoped lock (Guard<T>) is noncopyable.

>
> T* _ptr;
>
> Proxy(T* ptr, LockType& lock) : Guard<T>(lock), _ptr(ptr) {}
>
> T* operator->() {
> return _ptr;
> }
>
> }
>
> public:
>
> GuardedObject(T* object) : _object(object) {}
> ~GuardedObject() { delete _object; }
>
> Proxy operator->() {

Doesn't compile. Need a copy constructor to return by value.

> return Proxy(_object, _lock);
> }


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