Y
yuyang08
Hi,
I wrote a simple program to learn the usage of STL template
map and set. Although I did not give out any Compare function
with respect to struct A, the program got compiled without
any complain using g++. Could you explain why?
Many thanks!
#include <iostream>
#include <map>
#include <set>
using namespace std;
struct A{
int x, y;
};
int main()
{
A a1, a2;
a1.x = 5; a1.y = 6;
a2.x = 7; a2.y = 8;
map< pair<A*, A*> , int> test;
set< pair<A*, A*> > haha;
test.insert( make_pair( make_pair(&a1, &a2), 6) );
haha.insert( make_pair(&a1, &a2) );
return 0;
}
I wrote a simple program to learn the usage of STL template
map and set. Although I did not give out any Compare function
with respect to struct A, the program got compiled without
any complain using g++. Could you explain why?
Many thanks!
#include <iostream>
#include <map>
#include <set>
using namespace std;
struct A{
int x, y;
};
int main()
{
A a1, a2;
a1.x = 5; a1.y = 6;
a2.x = 7; a2.y = 8;
map< pair<A*, A*> , int> test;
set< pair<A*, A*> > haha;
test.insert( make_pair( make_pair(&a1, &a2), 6) );
haha.insert( make_pair(&a1, &a2) );
return 0;
}