Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2004-08-16 20:11:06

"Neal D. Becker" wrote

> Thanks for the links. I am currently using ublas for this. It has
> promote_traits in traits.hpp. This does what I need, and is part of the
> current boost release.

Sure... I am using Alex Gurtovoys, promotion_traits.hpp so I'll certainly
take a look.

One observation... As I have been moving along with my physical quantities
library, I have been discovered that 'generic' result_types
need this :

binary_operation<LHS,plus,RHS>::result_type operator + (LHS lhs, RHS rhs);

rather than

promote_traits <LHS,RHS>::result_type operator+(LHS,RHS);

Rationale ...for more complicated types results of (say) multiplication
arent the same as for (say) addition.
And for UDTs the value_types too may be compatible but different, so they
need nested result_types.

Another useful extension is to use enable_if, for selective overloading of
operator functions. I have wrapped this up in a modified binary_operation
binary_operation_if<Predicate,LHS,plus,RHS>::result_type operator + (LHS
lhs, RHS rhs);

This works well when multiplying UDTs by numerics ie int double etc, where
The predicate can be "is_this_value_type a compatible value_type for my
This can save a large amount of work overloading operator functions.

Andy Little

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