Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-12-03 15:38:09

Eric Niebler <eric_at_[hidden]> writes:

> 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.

Really? If invoked from within a template, global scope overloads
won't be found unless an argument is in the global namespace or the
overloads happen to appear before the point of definition of the

If you want a way to make this portable, consider adding a dummy
parameter that comes from namespace Boost and asking people to
overload there (the Ramey trick).

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at