|
Boost : |
Subject: Re: [boost] rvalue ref best practices?
From: Daniel Larimer (dlarimer_at_[hidden])
Date: 2012-06-09 18:48:16
On Jun 9, 2012, at 6:43 PM, Howard Hinnant wrote:
> On Jun 9, 2012, at 6:17 PM, Daniel Larimer wrote:
>
>> So, how much value is there to 'explicit copy only' types?
>
> If you want to your type to be copyable, but you also want to be able to monitor where it is getting copied unnecessarily, one approach is to give it traditional copy syntax, but temporarily disable that copy when you want to review: inspect whatever doesn't compile to see if you really want to be making a copy there.
>
> This technique is how I monitored the cost of std::list::size() in C++03: I just commented out std::list::size(), recompiled and observed what broke. Then fixed those places that were assuming that std::list::size() was O(1).
>
> Howard
>
This is what I had been doing, but the side effect is that the copy is not always *visible* in the code. Often times I would find a copy being made indirectly that I wanted to 'keep', but it was impossible to 'search' the code for it.
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk