K
kap
Hi all,
I am facing a weired problem when I try using maps. Here is the
sample code.
Can anyone please tell me where am I going wrong.
int main() {
less<int> ltvar;
std::map<int, int> m2(less<int>());
m2[1]; // compilation fails at this point
return 0;
}
whereas this particular code works fine
int main() {
less<int> ltvar;
std::map<int, int> m2( ltvar ); // less<int>() changed to ltvar
m2[1]; // compilation succeeds
return 0;
}
I would appreciate if someone can comment on what the issue is.
I am facing a weired problem when I try using maps. Here is the
sample code.
Can anyone please tell me where am I going wrong.
int main() {
less<int> ltvar;
std::map<int, int> m2(less<int>());
m2[1]; // compilation fails at this point
return 0;
}
whereas this particular code works fine
int main() {
less<int> ltvar;
std::map<int, int> m2( ltvar ); // less<int>() changed to ltvar
m2[1]; // compilation succeeds
return 0;
}
I would appreciate if someone can comment on what the issue is.