Boost logo

Boost :

From: Doug Gregor (gregod_at_[hidden])
Date: 2001-01-15 10:27:16


On Sunday 14 January 2001 10:51, you wrote:
> I don't see a benefit of the inheritance hierarchy for boost purposes. You
> say the benefit is that it reduces checking to a pointer conversion...
> but this makes little difference because causing the compiler error is
> easy. We could just as easily use boost static assert with is_associative.
>
> template <class Domain, class Op>
> class AssociativeConcept {
> public:
> void constraints() {
> function_requires< BinaryOpConcept<Domain, Op> >();
> BOOST_STATIC_ASSERT(is_associative<Domain, OP>::value);
> }
> };
>
> It looks like the above gets the job done, and is extremely simple.
>
> Are there other advantages to the inheritance hierarchy?

It reduces the amount of code the user is required to write to define the
behavior of a new data type. If I have written an arbitrary-precision
floating point, I'll need to specialize is_associative (twice),
is_commutative (twice), has_identity (twice), has_inverses and
is_distributive. If there is an inheritance hierarchy, I can just specify
that it is a field and all of the above properties are specified by the
refinement relationships.

        Doug


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