Boost logo

Boost :

From: Daniel Frey (d.frey_at_[hidden])
Date: 2005-03-08 03:29:31

Sylvain Pion wrote:
> I have been using boost/operators.hpp recently, and found it
> quite good at removing lines of code from my maintainance area :)
> I have some remarks about it :
> 1/
> The mixed operators are only provided if you know the type in
> advance and it is fixed. For example, it is not possible for
> example to mix with a template family of types. E.g. let's
> say that My_type has to provide mixed operators with all types
> X<U>. This is not possible to do with the current library.

Sounds reasonable, but I suspect some implementation problems. One might
try to provide new versions (with new names) of the
two-argument-template form with a template template parameter, but what
if X<U> is really a X<U,V=dummy<U> >?

FWIW, it seems to me that this is an unnecessary restriction of template
template parameters. Maybe someone of the standard gurus can explain to
me why I have to provide the arguments in the template declaration? IOW,
why not simply:

template< template X > class Y
    typedef X<int> Z; // Here(!), check if the expression is valid
    typedef X<int,std::allocator<int> > Z2; // Again

Of course, I'd like to hear about any other useful

> Another related thing is how to express "I want My_type to mix
> with all integral types". Maybe there could be a version of
> the operators that uses enable_if and tr1::is_integral somehow,
> for this purpose ?

I'd rather go for a more independent version, like

template< typename T > class addable_integral<T>
   : addable<T,int>,
     addable<T,unsigned int>,

[base class chaining omitted]

To sum it up, both ideas seem to be good. Do you have a patch? Something
that works, even if it's not yet boostified?

> 2/
> I think it is "Euclidean Ring", not "Euclidian Ring" ("e" instead of
> "i"), hence the names for euclidian_ring_operators<T> and similar,
> are unfortunate.

 From what I can see, both spellings seem to be used, where Google
offers "Do you mean Euclidean" for "Euclidian", but the latter has
3.500.000 hits against 1.500.000 for Euclidean. Strange. Also, look at
this: <>. So, my question is: What is
really correct? Can you (or someone else) give a reference?

Regards, Daniel

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