error 2678 no operator found with take a left-hand operand
#include <map>
#include <string>
using namespace std;
struct any {
any() {}
any(int x) {}
};
struct record : map<string, any> {
};
int main() {
record r;
r["aa"] = 123;
const any& a = r["aa"]; // ok
const record& cr = r;
const any& a = cr["aa"]; // error 2678
}
const record& cr = r;
auto const iter = cr.find("aa");
if (cr.end() != iter)
{
const any& a = iter->second;
}