|
Boost : |
From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-05-17 06:18:21
David Abrahams wrote:
> > Actually, isn't the unary plus operator a part of
> > (one-argument) 'addable' concept? IMO, expressions like +a
> > don't make much sense if you can't also write a1 + a2 and
> > a1 += a2, and, on the other hand, if the latter two are
> > allowed, is there a reason for not providing also the
> > +a form? As for me, right now I can't think of one.. so we
> > might have a chance to make the library more consistent and
> > get rid of the questionable name at the same time :).
>
> Maybe, though unless we're sure about this, I think the best
> solution for now is to simply remove it.
Agree, because I am still not sure.
> > Assuming that T's default constructor creates an equivalent
> > to zero<T>() (it's not a unreasonable assumption, is it?), the
> > following also could make sense
> > (although probably not very effective anyway):
> >
> > friend T operator-(const T& x) { return T() - x; },
> >
> > and probably not as a member of 'subtractable'. Just a thought :).
>
> As you say, it doesn't work well as a member of subtractable. Consider
> unsigned types and sets. So where are you proposing to put it?
Well, it could be something like 'unary_negatable' or 'algebraic_negatable',
but I am not really proposing to put it in the library, mostly because I am
not sure how useful it is. I would prefer to get some experience with this
definition before releasing it anywhere, unless someone will speak up for it
warmly :)
Aleksey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk