I've learned that passing a user-defined type to a std::map (as well as many other STL data structures) requires the definition of the operator <.
Doesn't that mean, however, that the compiler would be able to verify whether declarations of a std::map are correct at compile-time? The below code, which declares a std::map with a user-defined data-type that has no < operator, still compiles. Can somebody please tell me why this is true?
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
struct Test{
int a;
string b;
};
int main()
{
map <Test, int> M; // shouldn't this line cause a compilation error, as operator < is not defined
// for class Test?
return 0;
}