$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-07-03 08:43:07
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?
> ---
> 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
----------------------------------------------------------------------