How do I fix this error?
error C2668: ‘std::_Tree<_Traits>::end’ : ambiguous call to overloaded function
My code looks like this:
typedef map<int const *, float> my_map_t;
my_map_t _test;
my_map_t::const_iterator not_found = my_map_t::end();
if (_test.find(&iKeyValue) == not_found) {
_test[iKeyValue] = 4 + 5; // not the actual code, but here for simplicity
}
The compiler complains that there’s an ambiguous call to my_map_t::end(). This makes sense, because the only difference is the return type.
Normally you can disambiguate the call by casting the parameters, but end() has no parameters. Any ideas?
From your code, it appears that
my_map_t::end()is static (otherwise you’d have to call it on an instance, e.g._test.end()). Edit: Jesse Beder is right in his comment to the question; the code doesn’t make much sense, since_testis a type, not an object.Static member functions cannot be const-qualified (the const-qualification of a member function applies to the
thispointer; static member functions have nothispointer).