$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Douglas Gregor (gregod_at_[hidden])
Date: 2001-07-03 10:42:47
On Tuesday 03 July 2001 09:43, you wrote:
> On Mon, 2 Jul 2001, Douglas Gregor wrote:
> > Combiner function objects have a simple syntax: they take two input
> > iterators [first, last) and choose their value from the values returned
> > by the iterators. The value the combiner returns is the value returned by
> > the slot, i.e.,
>
> Quick question: why did you choose to have the user write the loop instead
> of calling std::inner_product with user-defined compare and combine
> function objects?
I'm not quite sure how std::inner_product would work - where is the second 
iterator range? Combiners take only one input iterator range [first, last)...
A possibility for taking the loop out of the user's hands would be to allow 
the user to specify an function object that:
        - Is invoked for each value returned by a slot.
        - Returns a boolean that says whether to stop or not
        - Has a "value" function that returns the final value
However, I think this approach is less familiar to users (there really isn't 
precedent for it in the standard library, AFAICT) than the iterator approach.
Also, I think just supplying a combiner that takes an iterator range is more 
flexible. One could use a signal or a boost::function object to combine the 
results of a signal call, which would be tough behavior to duplicate by just 
supplying a function object that gets invoked at each value.
> > ---
> > template<typename T>
> > struct max_or_default {
> >   typedef T result_type;
> >   template<typename InputIterator>
> >   typename InputIterator::value_type
> >   operator()(InputIterator first, InputIterator last) const
> >   {
> >     if (first == last)
> >       return T();
> >
> >     T max = *first++;
> >     for (; first != last; ++first)
> >       max = (*first > max)? *first : max;
> >
> >     return max;
> >   }
> > };
>
> ----------------------------------------------------------------------
>  Jeremy Siek                        www: http://www.lsc.nd.edu/~jsiek/
>  Ph.D. Candidate, IU B'ton          email: jsiek_at_[hidden]
>  Summer Manager, AT&T Research      phone: (973) 360-8185
> ----------------------------------------------------------------------
        Doug