Topic: Compilation of templates
Experts With ++, again I address to you for the help. While only I start to get acquainted with templates so there was such question, I will be grateful, if who on fingers explains, how it works.
Here there is a template class vector, and there is at it a comparison operator <. We do, , so:
vector <int> iv1, iv2; iv1.push_back (1); iv2.push_back (2); bool b = iv1> iv2;
And all works. And here if to try to compare vectors in which the objects lie, not defining comparison operator there will be a compilation error. And so I cannot understand, how it works. After all if to use a vector with incomparable elements, but not to cause comparing no errors arise. But after all the comparison operator there should be all the same certain, and the compiler should stumble about it. It turns out, vector all is compiled not completely at once, and in parts? That is, its operator <is not compiled, if is not caused anywhere and consequently in this case errors do not arise? Or it somehow on another is arranged? I, in view of poor knowledge With ++, cannot understand terrible source codes of standard library yet.