Boost logo

Boost :

From: Dan Gohman (gohmandj_at_[hidden])
Date: 2002-03-12 14:09:18


Here are some suggestions for operators.hpp based on some classes
that I've found to be useful. I haven't come up with good names for
them, though.

    // increasable?
    friend T& operator++(T& x) { return x += 1; }

    // decreasable?
    friend T& operator--(T& x) { return x -= 1; }

    friend T& operator-=(T& x, U const& y)
        { return x += -y; }

    friend bool operator<(T const& x, U const& y)
        { return x - y < 0; }

    // I haven't actually used these for anything.
    friend T operator-(T const& x) { return 0 - x; }
    friend T operator+(T const& x) { return x; }

Dan

-- 
Dan Gohman
gohmandj_at_[hidden]

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