Alf P. Steinbach said:
Technically yes, I think it does violate that rule.
Practically, no, I don't know any compiler that enforces that rule.
But you don't have to, just make your own class that forwards to
std::numeric_limits. A bit tedious, perhaps, but then you can fix some
things at the same time.
Yeah, even Comeau doesn't reject it, but performing this specialization sure
seems suspect to me! Comeau and VC++ 7.1 accept what's shown below without
so much as a warning.
Hmmm.... A class that forwards to std::numeric_limits<>... Interesting! I
assume that involves a class template named numeric_limits<> in my own
namespace (call it dave) and some sort of scheme to check if
std::numeric_limits<T>::is_specialized is true. If it is, that value is
used, otherwise I will expect that client code has specialized my
dave::numeric_limits with their numeric type. At least I think that would
be the gist of it...
#include <limits>
using namespace std;
struct foo_t
{
};
namespace std
{
template<>
class numeric_limits<foo_t>
{
public:
static const bool has_infinity = false;
};
}
int main()
{
(void) numeric_limits<foo_t>::has_infinity;
}