I'll let you try to talk me out of this inheritance in a minute*, but for now I'm hoping to find out why this error happens.
Here's a stripped down example that reproduces the issue in MSVC 2015:
template<typename key_type, typename value_type>
class my_unordered_map : public unordered_map<key_type, value_type>
{
public:
value_type& operator[](const key_type& key)
{
return unordered_map<key_type, value_type>::operator[](key);
}
};
int main()
{
my_unordered_map<string, int> m;
m["x"] = 42;
}
All that my_unordered_map is intending to do (so far) is override one member function and delegate the call to its overridden base member function. But I get the error is MSVC 2015:
binary '=': no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
Any thoughts why?
* Okay, so now you can try to talk me out of this inheritance. The gist is I want an unordered_map + one extra feature. But aside from that feature, I still want to retain the entire interface and implementation of unordered_map, and inheritance seems the most straightforward way to do that. And even though the language will allow it, I don't plan to switch between the two kinds of maps polymorphically, so virtual or lack of shouldn't be an issue.