|
Boost Users : |
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2007-03-07 16:19:54
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<your_custom_type1> : public
my_numeric_limits_impl<your_custom_type1>
{};
template<>
class numeric_limits<your_custom_type2> : public
my_numeric_limits_impl<your_custom_type2>
{};
}
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.
-----Original Message-----
From: james.jones_at_[hidden] [mailto:james.jones_at_[hidden]]
Sent: Mittwoch, 7. März 2007 22:12
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] [enable_if] using enable_if to
extendstd::numeric_limits?
From: me22 <me22.ca_at_[hidden]>
> 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_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net