J
jamesrjones
I'm writing a template library that models the IEEE754(r) decimal
arithmetic standard, and I'd like to provide numeric_limits<> for my
templates. The problem is that I'm not sure how to do this.
If I had a simple (untemplated) class T, it would be easy. But what I
have instead is a model of a decimal type (call it DecimalType). Most
of my free functions, operations, etc look like this:
template <typename DecimalType>
DecimalType
operator+ (const DecimalType& lhs, const DecimalType& rhs);
A DecimalType is then supposed to have a certain interface.
So what I'd like to do is this:
namespace std {
template <typename DecimalType>
class numeric_limits
{
// extensions go here
};
}
But I can't do that because std::numeric_limits is already defined. So
I need to be able to provide a partial specialization. But how can I
do this? (Note: I can see some ways to do it if DecimalType is
required to derive from an ABC, but I'd prefer not to do this.)
Thanks,
- James
arithmetic standard, and I'd like to provide numeric_limits<> for my
templates. The problem is that I'm not sure how to do this.
If I had a simple (untemplated) class T, it would be easy. But what I
have instead is a model of a decimal type (call it DecimalType). Most
of my free functions, operations, etc look like this:
template <typename DecimalType>
DecimalType
operator+ (const DecimalType& lhs, const DecimalType& rhs);
A DecimalType is then supposed to have a certain interface.
So what I'd like to do is this:
namespace std {
template <typename DecimalType>
class numeric_limits
{
// extensions go here
};
}
But I can't do that because std::numeric_limits is already defined. So
I need to be able to provide a partial specialization. But how can I
do this? (Note: I can see some ways to do it if DecimalType is
required to derive from an ABC, but I'd prefer not to do this.)
Thanks,
- James