Boost logo

Boost :

From: Sylvain Pion (Sylvain.Pion_at_[hidden])
Date: 2005-03-08 06:04:16


On Tue, Mar 08, 2005 at 09:29:31AM +0100, Daniel Frey wrote:
> 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
> technique/implementation...

The usual restriction of the template-template interface...
It is usually at this point that the rebind technique raises its ugly head :)

I am not familiar enough with MPL/enable_if/... to say if this can
be done nicely with those tools. I just vaguely suspect it is.

> >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?

I do not have any patch. I was just thinking loud about potential future
needs of mine or others. If I get to it, I'll send a patch of course.

> >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: <http://www.dictionary.net/euclidian>. So, my question is: What is
> really correct? Can you (or someone else) give a reference?

Indeed both orthographs seem to be correct. I had based my thought only on
the uses in Mathworld (http://mathworld.wolfram.com/EuclideanRing.html)
and CGAL. Notice that the ratio is reversed when looking for
"euclidean geometry" (357,000 hits) versus "euclidian geometry" (60,000 hits).

-- 
Sylvain

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