void foo( const std::unordered_map<char, int> & m )
{
using M = std::remove_const< decltype( m ) >;
M mutable_map;
mutable_map['a'] = 42;
}
This fails with "no match for operator[]". In my actual code I carry the map inside an std::pair and there the error message is clearer: "passing const std::unordered_map<...> as this discards qualifiers".
What's wrong? I can't use const_cast<>() because I don't know the type (the map template parameters).