Boost logo

Boost :

From: Nathan Myers (ncm_at_[hidden])
Date: 1999-12-07 21:07:42


Greg Colvin wrote:
> ... being a stickler for the
> return type of operator*() is not worth it. I'm not sure
> whether we have a library issue or not, but given that we
> have vector<bool> we will need to fix the ForwardIterator
> requirements so that vector<bool>::interator conforms. That
> fix might well apply to GGCL iterators.

The problem solved by requiring operator* to return an actual T&
is that template argument matching and type deduction cannot look
past conversions or other apparatus. I.e., if you have a template

  template <typename T>
    void foo(T&);

and you say

  foo(*it);

, then it.operator*() had better return a T&, or you get a compile
error. Casts are no help here, because the caller of foo() is little
more likely to know T than foo() is, and in any case it may not work
to convert it to a T&. (Typically, if it would, you would have
returned T& directly from operator*()).

Nathan Myers
ncm_at_[hidden]


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