
From: "Ovanes Markarian"
As I wrote before, you can specialize numeric_limits class with your custom type:
template<class T> struct my_numeric_limits_impl { static T min() { return boost::decimal::decimal_limits<T>::min(); } };
namespace std { template<> class numeric_limits
: public my_numeric_limits_impl {}; template<> class numeric_limits
: public my_numeric_limits_impl {}; }
What is wrong on this approach? The only problem I see here is the the customer must include the specialization of numeric limits. But this can be easily solved if you put in the same header where your_custom_type is defined. So everyone using yyour_custom_type will automatically include numeric_limits and if needed use the correct version.
I have no problem putting this in a standard include file. The problem I have is that I'm trying to make it as easy as possible for users to add their own models of my decimal type concept. I'd like for the steps to be as simple as: (a) define a new model and then (b) specialize is_decimal_type. So far I've been able to use (b) to drive lots of other functionality, and I'm frustrated that I can't get this to help with std::numeric_limits. But it sounds like there may be no perfect solution here.
Here's an example of how enable_if *has* helped me in this project. I'm defining a bunch of operators, e.g. operator+, which need to take arguments only of is_decimal_type objects. I can easily do this:
template