Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-03-29 14:48:12


On Thu, 29 Mar 2001, Mark Rodgers wrote:
mark.r>
mark.r> That would mean that the bound value would have to be default
mark.r> constructible, which currently it does not have to be. I'd be reluctant
mark.r> to impose additional constraints on what can be bound.
mark.r>
mark.r> If I were to add a default constructor that default initialised the
mark.r> function and the value, presumably that would not get instantiated
mark.r> if it wasn't used, so would be all right???? 14.7.1 para 1 seems to
mark.r> indicate that would be the case.

Right, the default constructor does not get instantiated if it is not
used, which is true for all member functions. Therefore, you aren't
doing any harm by adding it. You can still use the function object
with non default constructible bound values.

mark.r> However I don't quite understand why the function object "needs" to be
mark.r> contained in the iterator, and how a default constructed binder could
mark.r> possibly be useful.

The tranform iterator adaptor takes in a function object, and then applies
the function object as it dereferences the underlying iterator. I don't
see any other reasonable way to implement transform iterator without
containing the function object.

As for usefulnes: of course it is not useful, just as a defualt
constructed iterator is not useful *as is*... but when you later assign a
valid iterator to it, then it becomes useful.

Cheers,
Jeremy

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------


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