Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-12-03 14:51:46


MB wrote:
> Eric Niebler wrote:
>
>>
>>1) By default, only apply the optimization to boost:iterator_range and
>>its ilk, NOT to types derived from them.
>>
>>2) Leave the code as it is, and force people in your situation to use
>>the cheap_copy customization point to disable the optimization.
>>
>>I currently lean toward (1).
>
>
> I will vote for (2) only because almost all my ranges are
> cheap-copyable and derived from iterator_range :-)
>

OK, I've gone with (2) for now. There's still time to change it before
1.34 in case anyone hollers. I have turned cheap_copy into an ADL
customization point. It is now called boost_foreach_has_cheap_copy, and
you define an overload as:

inline boost::mpl::true_ *
boost_foreach_has_cheap_copy(your_type_here *)
{
     return 0;
}

Put the overload in an associated namespace of the type. Or for maximum
portability, you could put the overload at global scope.

For now, this is only in CVS, not in the foreach.zip in the File Vault.
I want to see what the regression tests look like before I inflict this
on the world.

Let me know if this hook helps you solve your problem, and I'll patch up
the documentation.

HTH,

-- 
Eric Niebler
Boost Consulting
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