I have created my own type, without any comparator, and without a specialization of std::numeric_limits. Despite that, for some reason, std::numeric_limits<MyType> compiles fine. Why did the c++ standards committee define the numeric_limits template such that it is valid for all types, including non-numeric types??
Example code below:
#include <iostream>
#include <limits>
using namespace std;
// This is an int wrapper that defaults to 666 instead of 0
class A {
public:
int x;
public:
A() : x(666) {}
};
int main() {
A a = std::numeric_limits<A>::max();
A b = std::numeric_limits<A>::max();
std::cout << a.x << "\n" << b.x;
// your code goes here
return 0;
}