Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2002-03-22 11:19:55

Aleksey Gurtovoy wrote:
> Daniel Frey wrote:
> > > What about operations on different types - Duration + Date
> > = Date, etc?
> >
> > I tried to merge Alexsey's code with some older code of mine. A first
> > version shows that you can combine them, but there are some problems
> > with the granularity (I mean, to specify which of the 'friends' should
> > be used. The code I have is this:
> Cool, I thought in the same direction! I don't think that granularity is
> really a problem, because, strictly speaking, these using declaration are
> unnecessary if you make the operators in the base template 'public'; if you

The problem is a semantic one: Do I really want to use all of the
operators as they are defined by operators<>? Sometimes, you might want
lots of them, but replace a special one with a user-supplied version (to
provide an optimized version for special operators or when mixing
types). But generally, I think we're on the right way. For
member-functions (member-operators), you can write your own version in
the derived class, it's only a problem for the friend-operators, as you
cannot override them.

> The only reason I went
> with 'protected' and 'using' declarations is because you _need_ 'using' for
> postfix increment and decrement (otherwise, they would be hidden by infix
> versions in the derived class), and I felt that consistent use of 'using'
> can be easy to remember and also has some nice documentation qualities.

I suggest dropping ++/-- and concentrate on the rest first, as it is the
bigger part and thus more valuable. It shouldn't be polluted or made
unnecessarily complex without a really good reason. Afterwards, we can
still add ++/--, be it consistent or not.

Regards, Daniel

Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web:

Boost list run by bdawes at, gregod at, cpdaniel at, john at