Re: [Boost-users] [enable_if] using enable_if to specialize std::numeric_limits?

From: "Ovanes Markarian" <om_boost@keywallet.com>
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<typename LHSType, typename RHSType> typename enable_if_c< is_decimal_type<LHSType>::value || is_decimal_type<RHSType>::value, typename result_type_2<LHSType, RHSType>::type>::type operator+(const LHSType& lhs, const RHSType& rhs) { typedef typename result_type_2<LHSType, RHSType>::type result_type; return result_type(operation_t::ADD, lhs, rhs); } Works great, and doesn't interfere with other specializations/overloads of operator+. - James Jones Administrative Data Mgmt. Webmaster 375 Raritan Center Pkwy, Suite A Data Architect Edison, NJ 08837
participants (1)
-
james.jones@firstinvestors.com