|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-07-08 13:46:13
Howard Hinnant <hinnant_at_[hidden]> writes:
> On Jul 8, 2004, at 11:10 AM, David Abrahams wrote:
>
>> Are there really any repercussions from making a noncopyable type into
>> a moveable type, other than that you might want to find ways to take
>> advantage of the new moveability?
>
> If I had an rvalue reference available today, I would design the
> interface of the read and write locks differently. For example,
> instead of:
>
> void f(rw_mutex& m)
> {
> rw_mutex::upgradable_read_lock r(m);
> if (...)
> {
> rw_mutex::write_lock w(r);
> //...
> w.transfer_to(r);
> }
> //Point A
> }
>
> I would propose:
>
> void f(rw_mutex& m)
> {
> rw_mutex::upgradable_read_lock r(m);
> if (...)
> {
> rw_mutex::write_lock w(move(r));
> //...
> r = move(w);
> }
> //Point A
> }
>
> The original code would not compile: write_lock would not accept an
> lvalue upgradable_read_lock and transfer_to would not exist.
I believe you can have the latter syntax with or without moveability.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk