Re: [Boost-users] [enable_if] using enable_if to extend std::numeric_limits?
From: me22
I don't think you can "extend" classes that already exist. Note, for example, that boost has integer_traits, and doesn't try to modify numeric_limits.
Why do you want the concept to be in numeric_limits? Can you not simply use is_decimal_type?
I should be more precise - by "extend" I really mean "specialize". I'd like to provide specializations for numeric_limits for my new decimal types. I can certainly just provide my own decimal_limits class (and have implemented this already), but the idea is to create a drop-in replacement for, say, double - and existing code likely uses numeric_limits<T> with T=double already, so being able to provide this with T=my_decimal_type would be ideal. - James Jones Administrative Data Mgmt. Webmaster 375 Raritan Center Pkwy, Suite A Data Architect Edison, NJ 08837
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
I don't think you can "extend" classes that already exist. Note, for example, that boost has integer_traits, and doesn't try to modify numeric_limits.
Why do you want the concept to be in numeric_limits? Can you not simply use is_decimal_type?
I should be more precise - by "extend" I really mean "specialize". I'd like to provide specializations for numeric_limits for my new decimal types. I can certainly just provide my own decimal_limits class (and have implemented this already), but the idea is to create a drop-in replacement for, say, double - and existing code likely uses numeric_limits<T> with T=double already, so being able to provide this with T=my_decimal_type would be ideal. - James Jones Administrative Data Mgmt. Webmaster 375 Raritan Center Pkwy, Suite A Data Architect Edison, NJ 08837 _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
james.jones@firstinvestors.com
-
Ovanes Markarian