I'm declaring my std::map and use it below:
map<int, int, function<bool (int, int)>> m;
m.insert(make_pair(12,3));
m.insert(make_pair(3,4));
for(auto & p : m){
cout << p.first << "," << p.second << endl;
}
g++ compiles, no error. Template parameter only requires a type, but no function body is required, passes compilation. I was wondering how this empty comparer would behave. On running it:
terminate called after throwing an instance of 'std::bad_function_call'
what(): bad_function_call
I only see this error in calling pure virtual function. But my code is using stl template, no polymorphism is in place.
So is this a c++ design issue, that compilation doesn't check if a function only has declaration but no function body to run? Plus, how would c++ standard deal with this?
Appreciate your explanations.