Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-01-29 23:29:05


Hi Doug,

This is going in the right direction... though I've done a couple
thought experiments and I think we still have a bunch of problems
to work through... I must admit, getting this right is going to
be a real challenge. I'll get back to you again after I've had
time to think about this more.

Cheers,
Jeremy

On Tue, 16 Jan 2001, Doug Gregor wrote:

gregod> On Monday 15 January 2001 10:51, you wrote:
gregod> > Good point. Ok, so I'm thinking about how to have the inheritance
gregod> > hierarchy, but also keep things simple... how about we do like the std
gregod> > iterators, define a hierarchy of simple tag classes, one tag for each
gregod> > algebra concept. This really has to be done anyways to allow for algorithm
gregod> > dispatching, and can also be used to check named conformance.
gregod>
gregod> Perhaps something along the lines of:
gregod>
gregod> ----------------------
gregod> struct unknown_tag {};
gregod> template<typename Op> struct associative_tag {};
gregod> template<typename Op> struct commutative_tag {};
gregod> template<typename Op> struct identity_tag {};
gregod> template<typename Op> struct inverses_tag {};
gregod> // ...
gregod> template<typename Op> struct semigroup_tag : associative_tag<Op> {};
gregod> template<typename Op> struct commutative_semigroup_tag : semigroup_tag<Op> ,
gregod> commutative_tag<Op> {};
gregod> template<typename Op> struct monoid_tag : semigroup_tag<Op>, identity_tag<Op>
gregod> {};
gregod> template<typename Op> struct abelian_monoid_tag : monoid_tag<Op>,
gregod> commutative_tag<Op>, commutative_semigroup_tag<Op> {}
gregod> template<typename Op> struct group_tag : monoid_tag<Op>, inverses_tag<Op>
gregod> template<typename Op> struct abelian_group_tag : group_tag<Op>,
gregod> commutative_tag<Op>, abelian_monoid_tag<Op> {}
gregod> // ...
gregod>
gregod> template<typename Domain>
gregod> struct algebra_traits
gregod> {
gregod> typedef unknown_tag category;
gregod> };
gregod>
gregod> // ...
gregod> template<>
gregod> struct algebra_traits<float>
gregod> {
gregod> typedef field_tag< std::plus<float>, std::mulitplies<float> > category;
gregod> };
gregod> -----------------------
gregod>
gregod> All inheritance in the above should be public virtual, I'm just too lazy to
gregod> type it out at the moment.
gregod>
gregod> Doug
gregod>
gregod>
gregod>
gregod>

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------


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