Boost logo

Boost :

From: Anatoli Tubman (anatoli_at_[hidden])
Date: 2004-04-25 04:31:25


Eric Niebler wrote:
> This is in reference to the following line of code:
> for (crange<int> const & r = mkrange(d); r; ++r)
>
> Making the assignment operator private would do nothing since it is not
> being called here.

Right, my bad.

> Making the copy constructor private wouldn't help
> either because the copy constructor must be accessible in order to bind
> a temporary to a const reference. (Not all compilers enforce this rule.)

The copy constructor is indeed called here, but if you forget the &,
a conversion constructor will be called if it's present. That should be
made private.

-- 
Anatoli Tubman
PTC Israel (Haifa)
Tel. (+972) 4-8550035 ext. 229

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