Boost logo

Boost :

From: Doug Gregor (gregod_at_[hidden])
Date: 2001-01-16 14:22:37


On Monday 15 January 2001 10:51, you wrote:
> Good point. Ok, so I'm thinking about how to have the inheritance
> hierarchy, but also keep things simple... how about we do like the std
> iterators, define a hierarchy of simple tag classes, one tag for each
> algebra concept. This really has to be done anyways to allow for algorithm
> dispatching, and can also be used to check named conformance.

Perhaps something along the lines of:

----------------------
struct unknown_tag {};
template<typename Op> struct associative_tag {};
template<typename Op> struct commutative_tag {};
template<typename Op> struct identity_tag {};
template<typename Op> struct inverses_tag {};
// ...
template<typename Op> struct semigroup_tag : associative_tag<Op> {};
template<typename Op> struct commutative_semigroup_tag : semigroup_tag<Op> ,
commutative_tag<Op> {};
template<typename Op> struct monoid_tag : semigroup_tag<Op>, identity_tag<Op>
{};
template<typename Op> struct abelian_monoid_tag : monoid_tag<Op>,
commutative_tag<Op>, commutative_semigroup_tag<Op> {}
template<typename Op> struct group_tag : monoid_tag<Op>, inverses_tag<Op>
template<typename Op> struct abelian_group_tag : group_tag<Op>,
commutative_tag<Op>, abelian_monoid_tag<Op> {}
// ...

template<typename Domain>
struct algebra_traits
{
  typedef unknown_tag category;
};

// ...
template<>
struct algebra_traits<float>
{
  typedef field_tag< std::plus<float>, std::mulitplies<float> > category;
};
-----------------------

All inheritance in the above should be public virtual, I'm just too lazy to
type it out at the moment.

        Doug


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