Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2000-10-02 22:37:47


I have a question about the following class from "operators.hpp" (after I
applying my changes, but the subject is between the brackets, and I didn't
change that part).

//===================================================================
template <class T,
          class V,
          class D = std::ptrdiff_t,
          class P = V*,
          class R = V&>
struct random_access_iterator_helper
  : random_access_iterator_operators<T, P, D, R
  , boost::iterator<std::random_access_iterator_tag, V, D, P, R
> >
{
#ifndef __BORLANDC__
  friend D requires_difference_operator(const T& x, const T& y) {
    return x - y;
  }
#endif
}; // random_access_iterator_helper
//===================================================================

I guess the "requires_difference_operator" is supposed to enforce the
iterator class (T) to support operator-(). Why is there a preprocessor
block around it based on Borland compilers? Does Borland add something to
make the function unnecessary, or is the construct always needed but
Borland's stuff is too stupid to accept it? If it is the latter, maybe we
should use a new Boost #define (in "config.hpp") instead?

Also, couldn't "requires_difference_operator" be private? We don't really
need to call it, it's just there to force the compiler to complain of
operator-() isn't found. Maybe it could be a private static function.

-- 

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