std::unordered_map with custom value type, operator[]
问题 I'm trying to use std::unordered_map, as shown in the example here. class CSVRecord { public: CSVRecord(string csvLine) : _fields(vector<string>()) {...} vector<string> _fields; }; int main(int argc, char* argv[]) { unordered_map<string, CSVRecord> m; CSVRecord rec = CSVRecord("test"); m["t"] = rec; return 0; } However, m["t"] = rec gives an error: no matching function for call to ‘CSVRecord::CSVRecord()’ . I used m.insert(pair<string, CSVRecord>("t",rec)) instead, but I wonder why the