|
Boost : |
From: rwgk (rwgk_at_[hidden])
Date: 2002-03-07 18:35:20
With the language features that are currently available
I find myself using (idea stolen from Blitz++):
// The default traits: the result type is the type of the lhs
argument.
template<typename TypeLHS, typename TypeRHS>
struct binary_operator_traits {
typedef TypeLHS arithmetic;
};
// The remainder of this file defines the traits where the
// result type is the type of the rhs argument.
template<>
struct binary_operator_traits<signed char, short > {
typedef short arithmetic;
};
// ... etc. etc.
In the future, assuming that typeof is accepted into the standard,
will I be able to do this ...
template<typename TypeLHS, typename TypeRHS>
struct binary_operator_traits {
typedef typeof(TypeLHS() + TypeRHS()) arithmetic;
};
... and avoid all the specializations?
Thanks,
Ralf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk